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

ext/sockets/sockets.c

index 9987856058aa62e45df822c21e96d31f16a1ebe4..2b7085c18d9276926c96b421334315ed9cedec6e 100644 (file)
@@ -859,7 +859,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;
        }