diff options
author | Wez Furlong <wez@php.net> | 2003-11-28 23:20:23 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2003-11-28 23:20:23 +0000 |
commit | 6d86bb9e40386e4127af4f55b8e8e79864255ca1 (patch) | |
tree | 9242744d6ca9f54179d01a7a957d59dbd7dfeaf8 | |
parent | 3f07e4364cae8499626d5db4a42cb2d4f6aa6af7 (diff) | |
download | php-git-6d86bb9e40386e4127af4f55b8e8e79864255ca1.tar.gz |
(sort of) MFB, feof fix for sockets.
-rw-r--r-- | ext/openssl/xp_ssl.c | 8 | ||||
-rwxr-xr-x | main/streams/streams.c | 8 | ||||
-rw-r--r-- | main/streams/xp_socket.c | 8 |
3 files changed, 21 insertions, 3 deletions
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 { |