From: Wez Furlong Date: Fri, 28 Nov 2003 22:11:34 +0000 (+0000) Subject: Fix for bug #25939; feof not working correctly for sockets. X-Git-Tag: php-4.3.5RC1~157 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f93c6a6a13a81053f5f17a6bcbe8b940000fae37;p=php Fix for bug #25939; feof not working correctly for sockets. Possibly also fixes #23220; warnings issued by fgets on ssl sockets. --- diff --git a/main/network.c b/main/network.c index ae32885cf8..01354cea3d 100644 --- a/main/network.c +++ b/main/network.c @@ -1139,8 +1139,14 @@ int _php_network_is_stream_alive(php_stream *stream) int alive = 1; int fd = sock->socket; fd_set rfds; - struct timeval tv = {0, 0}; + struct timeval tv; char buf; + + if (sock->timeout.tv_sec == -1) { + tv.tv_sec = FG(default_socket_timeout); + } else { + tv = sock->timeout; + } /* logic: if the select call indicates that there is data to * be read, but a read returns 0 bytes of data, then the socket diff --git a/main/streams.c b/main/streams.c index 636b92f7cf..62028f0a81 100755 --- a/main/streams.c +++ b/main/streams.c @@ -659,6 +659,10 @@ PHPAPI int _php_stream_eof(php_stream *stream TSRMLS_DC) if (stream->writepos - stream->readpos > 0) return 0; + if (!stream->eof && php_stream_is(stream, PHP_STREAM_IS_SOCKET)) { + stream->eof = !_php_network_is_stream_alive(stream); + } + return stream->eof; }