|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-10-09 09:31 UTC] andrei@php.net
[2000-10-09 10:48 UTC] tcarroll at chc-chimes dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 00:00:01 2025 UTC |
The following script illustrates the problem. //open some $sock socket_set_timeout( $sock, 45 ); if(!($ret = fread( $sock, 255 )) { //Happens randomly $status = socket_get_status( $sock ); if( $status['timeout'] ) echo 'I timed out!'; } The problem is in php_sockwait_for_data:ext/standard/file.c If a timeout is set, ptimeout is equated to a non-initialized variable. This explains the random timeout behavior a diff follow of fsock.c follows: --- /home/tcarroll/cvs-php/php4/ext/standard/fsock.c Sun Aug 27 00:14:47 2000 +++/home/tcarroll/php-4.0.2/ext/standard/fsock.c Fri Oct 6 16:14:22 2000 @@ -493,9 +493,9 @@ static void php_sockwait_for_data(php_sockbuf *sock) { - fd_set fdr, tfdr; + fd_set fdr; int retval; - struct timeval timeout, *ptimeout; + struct timeval *ptimeout; FD_ZERO(&fdr); FD_SET(sock->socket, &fdr); @@ -504,13 +504,10 @@ if (sock->timeout.tv_sec == -1) ptimeout = NULL; else - ptimeout = &timeout; + ptimeout = &sock->timeout; while(1) { - tfdr = fdr; - timeout = sock->timeout; - - retval = select(sock->socket + 1, &tfdr, NULL, NULL, ptimeout); + retval = select(sock->socket + 1, &fdr, NULL, NULL, ptimeout); if (retval == 0) sock->timeout_event = 1;