]> granicus.if.org Git - php/commitdiff
Fixed bug #35062 (socket_read() produces warnings on non blocking sockets).
authorIlia Alshanetsky <iliaa@php.net>
Sun, 4 Dec 2005 17:30:43 +0000 (17:30 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 4 Dec 2005 17:30:43 +0000 (17:30 +0000)
NEWS
ext/sockets/sockets.c

diff --git a/NEWS b/NEWS
index 84569d6113db8d7db855fa318b7c689539998aee..41a3a9a2552ff2caf7a7c6c3788cbf8553e2b1b2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -52,6 +52,8 @@ PHP                                                                        NEWS
 - Fixed bug #35381 (ssl library is not initialized properly). (Alan)
 - Fixed bug #35373 (HP-UX "alias not allowed in this configuration"). (Dmitry)
 - Fixed bug #35103 (mysqli handles bad unsigned (big)int incorrectly).(Andrey)
+- Fixed bug #35062 (socket_read() produces warnings on non blocking sockets).
+  (Nuno, Ilia)
 - Fixed bug #35028 (SimpleXML object fails FALSE test). (Marcus)
 
 28 Nov 2005, PHP 5.1.1
index 9113264a018532b1e7ad18bec7333f50e79d79bc..e36522b5cd939ba9351deb86f03ee48b6cc51e27 100644 (file)
@@ -861,7 +861,19 @@ PHP_FUNCTION(socket_read)
        }
 
        if (retval == -1) {
-               PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
+               /* if the socket is in non-blocking mode and there's no data to read,
+               don't output any error, as this is a normal situation, and not an error */
+               if (errno == EAGAIN
+#ifdef EWOULDBLOCK
+               || errno == EWOULDBLOCK
+#endif
+               ) {
+                       php_sock->error = errno;
+                       SOCKETS_G(last_error) = errno;
+               } else {
+                       PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
+               }
+
                efree(tmpbuf);
                RETURN_FALSE;
        }