in reply to Re^6: Nonblocking commands in Windows
in thread Nonblocking commands in Windows

I tried switching the header to text/plain but still don't get any output until task is complete.

It seems clear that the problem lies within the server/cgi interface. Ie. Apache is buffering the output until the perlscript completes? I don't use Apache so I can't confirm that. Did you try putting the output into a file and using a slurp'n'spit script with a final sleep to confirm that?

My solution to the problem of dealing with long running cgis is to spawn a new process detached from the webserver that opens a port, redirects the client to that port and then takes over managing the http comms for that client instance until the task is complete.

Essentially putting a http daemon into the script and taking the webserver completly out of the loop. At that point you have complete control and can choose to either just present the output as it is produced, or present a html status page that auto refreshes periodically until the output is done.

The nice thing about this solution is that if the client stops refreshing--gets bored with waiting and closes the page, then you can abort the long running task early and prevent it from tying up resources. You can also ensure that only one copy of a long running task is started for any given set of parameters.

However, I am reluctant to offer this solution as my inexperience with things cgi in general, and things Apache in particular, mean that there is quite likely a simpler fix already known for Apache.

I would strongly recommend that you re-ask your question in a new SoPW, referencing this one, but omitting any reference to Windows in the title of the new one. You should explicitly reference 'Apache 2.2' and 'long running CGI' in the title. Ie. "Buffering problem with Apache 2.2 and a long running CGI". That is more likely to receive attention from the Apache and web experts here abouts who tend to use *nix and skip windows questions.

I would also suggest that you confirm that you encounter the same problem using a long running Perl script in place of the java one. Something simple like

#!perl -w use strict; $| = 1; for( 1 .. 10,000 ) { print "$_: " . localtime; sleep 1; }

before you re-post the question, and assuming that still demonstrates it, use that in place of the java script. It just removes one more unknown and means that those inclined to do so, will be able to reproduce your problem.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."