]> granicus.if.org Git - php/commitdiff
Fixed bug #43782 (feof() does not detect timeout on socket)
authorDavid Soria Parra <dsp@php.net>
Tue, 26 Aug 2008 16:06:23 +0000 (16:06 +0000)
committerDavid Soria Parra <dsp@php.net>
Tue, 26 Aug 2008 16:06:23 +0000 (16:06 +0000)
# Poll returns 0 if it times out.
# We check for 0 and use the user set timeout in set_options by passing -1.

main/streams/streams.c
main/streams/xp_socket.c

index 3d7d251ee3dd4bb837cdee07b894658699d75b50..8ca087727addd070e33dc419e3712184b0ef43e8 100755 (executable)
@@ -831,7 +831,7 @@ PHPAPI int _php_stream_eof(php_stream *stream TSRMLS_DC)
        /* 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;
        }
 
index a51c704e6360b0873012f034a4db78a3530fdde0..ab304e1f8df5669aaba80f3e2fff1fc68703c8a0 100644 (file)
@@ -280,8 +280,12 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void
 
                                if (sock->socket == -1) {
                                        alive = 0;
-                               } else if (php_pollfd_for(sock->socket, PHP_POLLREADABLE|POLLPRI, &tv) > 0) {
-                                       if (0 == recv(sock->socket, &buf, sizeof(buf), MSG_PEEK) && php_socket_errno() != EAGAIN) {
+                               } else {
+                                       if (php_pollfd_for(sock->socket, PHP_POLLREADABLE|POLLPRI, &tv) > 0) {
+                                               if (0 == recv(sock->socket, &buf, sizeof(buf), MSG_PEEK) && php_socket_errno() != EAGAIN) {
+                                                       alive = 0;
+                                               }
+                                       } else {
                                                alive = 0;
                                        }
                                }