]> granicus.if.org Git - php/commitdiff
Fix for bug #25939; feof not working correctly for sockets.
authorWez Furlong <wez@php.net>
Fri, 28 Nov 2003 22:11:34 +0000 (22:11 +0000)
committerWez Furlong <wez@php.net>
Fri, 28 Nov 2003 22:11:34 +0000 (22:11 +0000)
Possibly also fixes #23220; warnings issued by fgets on ssl sockets.

main/network.c
main/streams.c

index ae32885cf8d04de6d9509893b5be9063460780c5..01354cea3d33b1cb1f164687bc7b0bb079e158b8 100644 (file)
@@ -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
index 636b92f7cf9ff9001b719d40b23bdb4dde2a1682..62028f0a811425e420fd6a62c3b3c497cec12d6f 100755 (executable)
@@ -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;
 }