]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #43782 (feof() does not detect timeout on socket)
authorDavid Soria Parra <dsp@php.net>
Tue, 26 Aug 2008 16:06:36 +0000 (16:06 +0000)
committerDavid Soria Parra <dsp@php.net>
Tue, 26 Aug 2008 16:06:36 +0000 (16:06 +0000)
NEWS
main/streams/streams.c
main/streams/xp_socket.c

diff --git a/NEWS b/NEWS
index 9cc9563b5dd493f0d48a8b1bf991baed45d5b9db..14700be2682a6e329f3a96ba8391172b8314d1ad 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -50,6 +50,7 @@ PHP                                                                        NEWS
   duplicate keys). (Dmitry)
 - Fixed bug #43817 (opendir() fails on Windows directories with parent
   directory unaccessible). (Dmitry)
+- Fixed bug #43782 (feof() does not detect timeout on socket). (David Soria Parra)
 - Fixed bug #43008 (php://filter uris ignore url encoded filternames and can't
   handle slashes). (Arnaud)
 - Fixed bug #35980 (touch() works on files but not on directories). (Pierre)
index b5e618a72802778db6aed78408b249e8a215d580..65421c299d2371429777d60099bd681c19178465 100755 (executable)
@@ -642,7 +642,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 a7736878f4fcf838d815a58bfed57034297483e4..0684d1ae766b6e071a78ceabb8aca32a40aa4b60 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;
                                        }
                                }