From ac47448abb477be99963f0b38fe82ffe78c21a8b Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Sat, 2 Feb 2013 15:43:05 +0100 Subject: [PATCH] Ignore warnings on EAGAIN/EWOULDBLOCK/EINPROGRESS See bug #63570 --- ext/sockets/php_sockets.h | 4 +++- ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt | 4 ++-- ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt | 4 ++-- ext/sockets/tests/socket_sentto_recvfrom_unix.phpt | 5 ++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ext/sockets/php_sockets.h b/ext/sockets/php_sockets.h index 3762e026aa..9c5dc5a4aa 100644 --- a/ext/sockets/php_sockets.h +++ b/ext/sockets/php_sockets.h @@ -69,7 +69,9 @@ PHP_SOCKETS_API int php_sockets_le_socket(void); int _err = (errn); /* save value to avoid repeated calls to WSAGetLastError() on Windows */ \ (socket)->error = _err; \ SOCKETS_G(last_error) = _err; \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s [%d]: %s", msg, _err, php_strerror(_err TSRMLS_CC)); \ + if (_err != EAGAIN && _err != EWOULDBLOCK && _err != EINPROGRESS) { \ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s [%d]: %s", msg, _err, php_strerror(_err TSRMLS_CC)); \ + } \ } while (0) ZEND_BEGIN_MODULE_GLOBALS(sockets) diff --git a/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt b/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt index bf95044d48..00d69a855f 100644 --- a/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt +++ b/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt @@ -14,7 +14,7 @@ if (!extension_loaded('sockets')) { if (!socket_set_nonblock($socket)) { die('Unable to set nonblocking mode for socket'); } - socket_recvfrom($socket, $buf, 12, 0, $from, $port); // cause warning + var_dump(socket_recvfrom($socket, $buf, 12, 0, $from, $port)); //false (EAGAIN - no warning) $address = '127.0.0.1'; socket_sendto($socket, '', 1, 0, $address); // cause warning if (!socket_bind($socket, $address, 1223)) { @@ -44,7 +44,7 @@ if (!extension_loaded('sockets')) { socket_close($socket); --EXPECTF-- -Warning: socket_recvfrom(): unable to recvfrom [%d]: %a in %s on line %d +bool(false) Warning: Wrong parameter count for socket_sendto() in %s on line %d diff --git a/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt b/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt index 2beb8080cd..bd07904277 100644 --- a/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt +++ b/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt @@ -18,7 +18,7 @@ require 'ipv6_skipif.inc'; if (!socket_set_nonblock($socket)) { die('Unable to set nonblocking mode for socket'); } - socket_recvfrom($socket, $buf, 12, 0, $from, $port); // cause warning + var_dump(socket_recvfrom($socket, $buf, 12, 0, $from, $port)); // false (EAGAIN, no warning) $address = '::1'; socket_sendto($socket, '', 1, 0, $address); // cause warning if (!socket_bind($socket, $address, 1223)) { @@ -48,7 +48,7 @@ require 'ipv6_skipif.inc'; socket_close($socket); --EXPECTF-- -Warning: socket_recvfrom(): unable to recvfrom [11]: Resource temporarily unavailable in %s on line %d +bool(false) Warning: Wrong parameter count for socket_sendto() in %s on line %d diff --git a/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt b/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt index 55ad75c65e..e25bf4df1a 100644 --- a/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt +++ b/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt @@ -18,7 +18,7 @@ if (!extension_loaded('sockets')) { if (!socket_set_nonblock($socket)) { die('Unable to set nonblocking mode for socket'); } - socket_recvfrom($socket, $buf, 12, 0, $from, $port); // cause warning + var_dump(socket_recvfrom($socket, $buf, 12, 0, $from, $port)); //false (EAGAIN, no warning) $address = sprintf("/tmp/%s.sock", uniqid()); if (!socket_bind($socket, $address)) { die("Unable to bind to $address"); @@ -53,8 +53,7 @@ if (!extension_loaded('sockets')) { ?> --EXPECTF-- Warning: socket_create(): Unable to create socket [%d]: Protocol not supported in %s on line %d - -Warning: socket_recvfrom(): unable to recvfrom [%d]: Resource temporarily unavailable in %s on line %d +bool(false) Warning: socket_sendto() expects at least 5 parameters, 4 given in %s on line %d bool(false) -- 2.40.0