From: Wez Furlong Date: Fri, 28 Nov 2003 23:20:23 +0000 (+0000) Subject: (sort of) MFB, feof fix for sockets. X-Git-Tag: php-5.0.0b3RC1~554 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6d86bb9e40386e4127af4f55b8e8e79864255ca1;p=php (sort of) MFB, feof fix for sockets. --- diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index be5d9afedb..9a5732583e 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -437,10 +437,16 @@ static int php_openssl_sockop_set_option(php_stream *stream, int option, int val case PHP_STREAM_OPTION_CHECK_LIVENESS: { fd_set rfds; - struct timeval tv = {0,0}; + struct timeval tv; char buf; int alive = 1; + if (sslsock->s.timeout.tv_sec == -1) { + tv.tv_sec = FG(default_socket_timeout); + } else { + tv = sslsock->s.timeout; + } + if (sslsock->s.socket == -1) { alive = 0; } else { diff --git a/main/streams/streams.c b/main/streams/streams.c index b64cb5bdac..2089281741 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -602,6 +602,12 @@ PHPAPI int _php_stream_eof(php_stream *stream TSRMLS_DC) return 0; } + if (!stream->eof && PHP_STREAM_OPTION_RETURN_ERR == + php_stream_set_option(stream, PHP_STREAM_OPTION_CHECK_LIVENESS, + 0, NULL)) { + stream->eof = 1; + } + return stream->eof; } @@ -1113,7 +1119,7 @@ PHPAPI int _php_stream_set_option(php_stream *stream, int option, int value, voi break; default: - ret = PHP_STREAM_OPTION_RETURN_ERR; + ; } } diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index 55c6990957..ae7e8844f6 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -203,10 +203,16 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void case PHP_STREAM_OPTION_CHECK_LIVENESS: { fd_set rfds; - struct timeval tv = {0,0}; + struct timeval tv; char buf; int alive = 1; + if (sock->timeout.tv_sec == -1) { + tv.tv_sec = FG(default_socket_timeout); + } else { + tv = sock->timeout; + } + if (sock->socket == -1) { alive = 0; } else {