|
Posted by Bart Van der Donck on 05/20/06 12:40
Hello,
My Apache is configured so that it times out after ca. 2 and a half
minutes. For example, the following CGI script would have a time out
(because it runs longer than 2:30):
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
for (0..1000) {
print "seconds running: $_<br>\n";
sleep 1;
}
But, if I add a line $|++ , Apache doesn't time-out:
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
$|++;
for (0..1000) {
print "seconds running: $_<br>\n";
sleep 1;
}
$| (or $OUTPUT_AUTOFLUSH in full) is a special variable in Perl. It
makes the output of my CGI script unbuffered if its value is greater
than 0. This second script keeps outputting to the browser (unbuffered)
:
seconds running: 0
seconds running: 1
seconds running: 2
...
seconds running: 1000
Because Apache has "something to keep outputting" all the time, it
doesn't give a time-out here. Though in the first script, Apache waits
until the script has ended before output. Which thus triggers the
time-out and causes my script to end prematurely.
The problem I'm facing is that I have the same issue in PHP when
creating a large ZIP-file on-the-fly (more specifically in PhpMyAdmin's
export interface). I searched the PHP docs for "buffer" but none of
those functions seem to be suitable for what I want to do. Is this
possible in PHP ?
Thank you,
--
Bart
Navigation:
[Reply to this message]
|