php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14542 register_shutdown_function() timeout problem
Submitted: 2001-12-16 02:22 UTC Modified: 2003-01-22 23:17 UTC
Votes:4
Avg. Score:5.0 ± 0.0
Reproduced:4 of 4 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: dward at maidencreek dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.3.0 OS: Linux 2.4.5
Private report: No CVE-ID:
 [2001-12-16 02:22 UTC] dward at maidencreek dot com
It seems that when a script terminates due to a
timeout connection_status() returns 0 (and
connection_timeout() no longer exists).

When aborted by a user connection_status() does return 1.

Sample script:

<?PHP
set_time_limit(1);
register_shutdown_function("shutdown");

function shutdown(){
$status = connection_status();
$err = "Connection status ($status).\n";
error_log($err, 3, "/tmp/phpstatus.log");
}

while(true){
        echo ".";
}

?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-25 16:07 UTC] charmaine dot tian at contec-innovations dot com
The cause of the bug is that the following code is commented out in the timeout handler (zend_timeout() in zend_execute_API):

        /* is there any point in this?  we're terminating the request anyway...
        PG(connection_status) |= PHP_CONNECTION_TIMEOUT;
        */

In our case, we need this error status to be set correctly. We want to be able to detect the error when a script is terminated due to timeout.
 [2003-01-22 23:17 UTC] sniper@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 [2003-06-15 16:54 UTC] sergio at libero dot it
This bug has been not fixed on win32.
I've tried to execute this script
<?PHP
set_time_limit(1);
register_shutdown_function("shutdown");

function shutdown(){
$status = connection_status();
$err = "Connection status ($status).\n";
error_log($err, 3, "/temp/phpstatus.log");
}

while(true){
        echo ".";
}
?>

PHP says:
Fatal error: Maximum execution time of 1 second exceeded in C:\Inetpub\wwwroot\php\mynewsgate\shutdown.php on line 11

Fatal error: Maximum execution time of 1 second exceeded in C:\Inetpub\wwwroot\php\mynewsgate\shutdown.php on line 6

I've used PHP 4.3.2 on windows xp
 [2003-06-16 14:02 UTC] jason at thinkingman dot org
I concur -- this has NOT been fixed for Win32.  Please (someone) fix.  Need to be able to handle timeouts correctly.

I used the following code under PHP 4.3.2

<?
	set_time_limit(1);

	function test() {
		echo connection_status();
		echo "Processing timeout - line1\n";
		echo "Processing timeout - line2\n";
	}

	register_shutdown_function('test');



	while(1);
?>
 [2003-06-16 14:04 UTC] jason at thinkingman dot org
My BUG REPORT [marked BOGUS] contains important notes:
http://bugs.php.net/bug.php?id=17461
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 24 21:01:55 2014 UTC