Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

CGI form processing - multiple 'calls'

by waris (Initiate)
on Sep 03, 2002 at 00:12 UTC ( #194655=perlquestion: print w/replies, xml ) Need Help??

waris has asked for the wisdom of the Perl Monks concerning the following question:

I'm a novice. The server I'm dealing with is WinNT using Xitami (no, I don't have a choice about this). I have a perl script running when a form is submitted which includes a file upload function from the user. Since the files can be very large, the perl script can be open & in use for several minutes. I have to wait until the file is finished uploading in order to finish manipulating the data and return feedback to the user before closing the script. It works fine for one user, but not if a second submits before the first one is completed. I have seen a lot of mention about 'forking' but understand it won't work in the Windows environment. Is there a simple solution to this that works with Windows? Two related questions: can I run a Perl script when an HTML page opens (such as onLoad). Similarly can I run a Perl script when a page closes? if so, any info on how would be appreciated. Thank you.

Replies are listed 'Best First'.
Re: CGI form processing - multiple 'calls'
by fglock (Vicar) on Sep 03, 2002 at 00:24 UTC

    Looks like you need a separate program (a "daemon") to process the data. Keep it running in the server computer, checking for new data, and make it write appropriate "status" files. Your CGI program will only "monitor" what the "daemon" is doing.

    I've used this approach some times under Windows, I think it is the easier (and maybe the best) approach.

    If you let the CGI program do all the processing, you may run out of server processes and your clients will get "500 server error" because they can't connect until everything is done.

    such as onLoad

    Looks like Activestate perl has support for that, but you must have installed on the client side.

Re: CGI form processing - multiple 'calls'
by uwevoelker (Pilgrim) on Sep 03, 2002 at 09:22 UTC should be able to simultaneously upload files. The problem could be the rest of your script - do you use file locking?

    To your second question: No. But you can use JavaScript to redirect to /cgi-bin/ (and so on).

Re: CGI form processing - multiple 'calls'
by thpfft (Chaplain) on Sep 03, 2002 at 09:47 UTC

    to paraphrase: during the long upload period your application or the data it uses is in an in-between state such that other users should not be allowed to perform the same or similar operations?

    you need either a queue (perhaps) or a lock (definitely). That could be something as simple as creating a lockfile during the upload and deleting it at the end of the processing step: if the lockfile exists, you just warn the other user that they'll have to wait.

    You would need a mechanism for dealing with dropped connections, stop buttons and other user problems that might result in the upload being incomplete and the lockfile remaining, though. an age limit for the file would probably be part of that, along with (eg) email notification of the person whose upload failed.

    it does sound like perhaps you should reconsider the input mechanism, but without knowing more I can't say anything sensible about that.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://194655]
Approved by Aristotle
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2022-06-28 21:35 GMT
Find Nodes?
    Voting Booth?
    My most frequent journeys are powered by:

    Results (92 votes). Check out past polls.