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

diff --git a/NEWS b/NEWS
index 301598f96e36954391cd0b374f82e3628304bf54..5798e3e2a5c8dae8ee0bd498e06821cfd00feb09 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -86,6 +86,7 @@ PHP                                                                        NEWS
 - Fixed bug #43993 (mb_substr_count() behaves differently to substr_count() with
   overlapping needles). (Moriyoshi)
 - Fixed bug #43941 (json_encode silently cuts non-UTF8 strings). (Stas)
+- Fixed bug #43782 (feof() does not detect timeout on socket). (David Soria Parra)
 - Fixed bug #42737 (preg_split('//u') triggers a E_NOTICE with newlines).
   (Nuno)
 - Fixed bug #42604 ("make test" fails with --with-config-file-scan-dir=path).
index 7349bb14800d6fec864418a68a42c81c4e346032..c18c17e7362e1758c7b38bbf3a620db28fe87423 100755 (executable)
@@ -633,7 +633,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 5e074a0ca0b579a853a2ae22a9d3de27c434cb0f..e181feb94b16fd4723b13fb59b1266e8ef55f936 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;
                                        }
                                }