Skip to content

Commit 15afc78

Browse files
author
Ilia Alshanetsky
committed
Fixed bug #35062 (socket_read() produces warnings on non blocking sockets).
1 parent b01f5b3 commit 15afc78

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ PHP NEWS
5252
- Fixed bug #35381 (ssl library is not initialized properly). (Alan)
5353
- Fixed bug #35373 (HP-UX "alias not allowed in this configuration"). (Dmitry)
5454
- Fixed bug #35103 (mysqli handles bad unsigned (big)int incorrectly).(Andrey)
55+
- Fixed bug #35062 (socket_read() produces warnings on non blocking sockets).
56+
(Nuno, Ilia)
5557
- Fixed bug #35028 (SimpleXML object fails FALSE test). (Marcus)
5658

5759
28 Nov 2005, PHP 5.1.1

ext/sockets/sockets.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,19 @@ PHP_FUNCTION(socket_read)
861861
}
862862

863863
if (retval == -1) {
864-
PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
864+
/* if the socket is in non-blocking mode and there's no data to read,
865+
don't output any error, as this is a normal situation, and not an error */
866+
if (errno == EAGAIN
867+
#ifdef EWOULDBLOCK
868+
|| errno == EWOULDBLOCK
869+
#endif
870+
) {
871+
php_sock->error = errno;
872+
SOCKETS_G(last_error) = errno;
873+
} else {
874+
PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
875+
}
876+
865877
efree(tmpbuf);
866878
RETURN_FALSE;
867879
}

0 commit comments

Comments
 (0)