ID: 30301 Comment by: mike at dodgeit dot com Reported By: phpbug at zone-mr dot ath dot cx Status: No Feedback Bug Type: IIS related Operating System: Windows 2003 Server PHP Version: 5.0.2 New Comment:
How about fixing this bug thats been open since 2004!!! Previous Comments: ------------------------------------------------------------------------ [2007-04-19 05:14:30] benb at dpac dot tas dot gov dot au I too am experiencing this problem with Apache 2.2.4 and PHP 5.2.1 on Ubuntu. Kernel 2.6. Using a similar script to the one listed above. Connection_status() returns 0, as does connection_aborted. However I am streaming video. When streaming this amount of data, the connection does in fact hang as the image data can't make it to the client. I added a shutdown function with register_shutdown_function() to verify this though. Several minutes after my on-disk log file stops recording data being sent, the shutdown function writes a message to the same log file to say that the script has finally been terminated. So i'm assuming that apache is still trying to send data to the client even though they're no longer listening and it's the apache write_timeout that's finally killing the thread. Because the script is effectively dead in the water while waiting for data to be received by the client, i can't put in any timeout code to compensate. So i'm about to try and put a set_time_limit(10) call before each data transmission so that an output hang is (hopefully) handled after 10 seconds rather than several minutes. It would be great though if this was fixed. It would make life so much easier! ------------------------------------------------------------------------ [2007-02-13 21:02:32] akravtsov at rogers dot com I am having the same problem! I have tried everything. This has not been fixed since Oct 2004?? This is my code: <?php //ob_end_flush(); //This should make it work: set_time_limit(0); ignore_user_abort(false); error_reporting(E_ALL); ini_set("max_execution_time", "0"); $x = 0; $error = fopen("file.txt", "a"); echo "Beginning neverending loop"; //Alternate method register_shutdown_function("help"); while($x < 40) { //ob_end_clean(); //ob_start(); $xx = $x."__Connstat: ".connection_status()."Aborted? ".connection_aborted()."\r\n\r\n"; echo $xx; fwrite($error, $xx, strlen($xx)); //This is written fine. $x++; flush(); //If I include this flush, the program stops when I hit the stop button. If I don't, it doesn't stop even if I hit the stop button. sleep(1); if(connection_status() != 0 || connection_aborted()) { $msg = "QUIT"; fwrite($error, $msg, strlen($msg)); exit(); } } function help() { $f = fopen("test.txt", "a"); $m = "QUIT"; fwrite($f, $m, strlen($m)); fclose($f); exit(); } ?> ------------------------------------------------------------------------ [2006-02-08 14:30:09] phpbug at paragontech dot com Try to do a ob_end_flush(); at the top of your script. ------------------------------------------------------------------------ [2005-10-18 22:16:29] ecarpenter at itex dot co dot za I am having the same problem on SuSE Linux 9.3 running Linux 2.6.11.4-21.9-default, Apache 2.0.53 and PHP 4.3.10 (cli) (built: Aug 31 2005 16:14:46) The script below can be used to recreate the problem. After I have press the Stop button (Firefox 1.0.7) the script continues to execute until it is killed 15 minutes later without the shutdown function being executed. <? function foo() { exec("echo '".date("Y/m/d H:i:s")." Terminating Status:".connection_status()."' >> /tmp/test"); } register_shutdown_function('foo'); exec("echo '".date("Y/m/d H:i:s")." Starting' > /tmp/test"); $count=0; while (true) { $count++; exec("echo '".date("Y/m/d H:i:s")." Running ".$count." Status:".connection_status()."' >> /tmp/test"); } ?> ------------------------------------------------------------------------ [2005-10-11 10:51:26] klimov at mmk dot ru I have tried PHP 4.4.0 and 5.0.5 and latest cvs. My server is running on Windows 2003 with IIS 6. The functions connection_aborted and connection_status doesn't work properly too. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/30301 -- Edit this bug report at http://bugs.php.net/?id=30301&edit=1