summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2005-12-04 17:30:43 +0000
committerIlia Alshanetsky <iliaa@php.net>2005-12-04 17:30:43 +0000
commit15afc78f856439cfe78c9cd501b48b45f7e38553 (patch)
tree17798f0e47fc279a6149e54c56ed0f4ccb0c61e2
parentb01f5b35f516ac3a83527a6cb82bf800d9491a62 (diff)
downloadphp-git-15afc78f856439cfe78c9cd501b48b45f7e38553.tar.gz
Fixed bug #35062 (socket_read() produces warnings on non blocking sockets).
-rw-r--r--NEWS2
-rw-r--r--ext/sockets/sockets.c14
2 files changed, 15 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 84569d6113..41a3a9a255 100644
--- 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
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index 9113264a01..e36522b5cd 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -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;
}