wez Wed Feb 4 17:46:45 2004 EDT Modified files: /php-src/main/streams streams.c transports.c xp_socket.c Log: Fix a bug in the persistent socket liveness checks and feof(); they were using the default socket timeout of 60 seconds before returning the socket to the calling script. The reason they were using that value is that the same code is used for feof(), so the fix is allowing the caller to indicate the timeout value for liveness checks. A possible remaining issue now is that 0 second timeout[1] for pfsockopen is possibly too short; it's impossible to specify a sane value for all possible uses, so maybe we need a stream context or an .ini option to control this, or maybe use the timeout value that was passed to pfsockopen(). # [1] by timeout, I mean the time that PHP will wait for data on a # persistent socket before deciding if a new connection should be made; # NOT the timeout while waiting for a new connection to be established. http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.48&r2=1.49&ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.48 php-src/main/streams/streams.c:1.49 --- php-src/main/streams/streams.c:1.48 Wed Jan 28 17:21:54 2004 +++ php-src/main/streams/streams.c Wed Feb 4 17:46:44 2004 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c,v 1.48 2004/01/28 22:21:54 pollita Exp $ */ +/* $Id: streams.c,v 1.49 2004/02/04 22:46:44 wez Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -602,9 +602,10 @@ return 0; } + /* use the configured timeout when checking eof */ if (!stream->eof && PHP_STREAM_OPTION_RETURN_ERR == php_stream_set_option(stream, PHP_STREAM_OPTION_CHECK_LIVENESS, - 0, NULL)) { + -1, NULL)) { stream->eof = 1; } http://cvs.php.net/diff.php/php-src/main/streams/transports.c?r1=1.11&r2=1.12&ty=u Index: php-src/main/streams/transports.c diff -u php-src/main/streams/transports.c:1.11 php-src/main/streams/transports.c:1.12 --- php-src/main/streams/transports.c:1.11 Tue Jan 27 17:40:44 2004 +++ php-src/main/streams/transports.c Wed Feb 4 17:46:44 2004 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: transports.c,v 1.11 2004/01/27 22:40:44 wez Exp $ */ +/* $Id: transports.c,v 1.12 2004/02/04 22:46:44 wez Exp $ */ #include "php.h" #include "php_streams_int.h" @@ -74,6 +74,8 @@ if (persistent_id) { switch(php_stream_from_persistent_id(persistent_id, &stream TSRMLS_CC)) { case PHP_STREAM_PERSISTENT_SUCCESS: + /* use a 0 second timeout when checking if the socket + * has already died */ if (PHP_STREAM_OPTION_RETURN_OK == php_stream_set_option(stream, PHP_STREAM_OPTION_CHECK_LIVENESS, 0, NULL)) { return stream; } http://cvs.php.net/diff.php/php-src/main/streams/xp_socket.c?r1=1.21&r2=1.22&ty=u Index: php-src/main/streams/xp_socket.c diff -u php-src/main/streams/xp_socket.c:1.21 php-src/main/streams/xp_socket.c:1.22 --- php-src/main/streams/xp_socket.c:1.21 Thu Jan 8 03:17:59 2004 +++ php-src/main/streams/xp_socket.c Wed Feb 4 17:46:44 2004 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: xp_socket.c,v 1.21 2004/01/08 08:17:59 andi Exp $ */ +/* $Id: xp_socket.c,v 1.22 2004/02/04 22:46:44 wez Exp $ */ #include "php.h" #include "ext/standard/file.h" @@ -230,10 +230,14 @@ char buf; int alive = 1; - if (sock->timeout.tv_sec == -1) { - tv.tv_sec = FG(default_socket_timeout); + if (value == -1) { + if (sock->timeout.tv_sec == -1) { + tv.tv_sec = FG(default_socket_timeout); + } else { + tv = sock->timeout; + } } else { - tv = sock->timeout; + tv.tv_sec = value; } if (sock->socket == -1) {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php