From: Anatol Belski Date: Tue, 11 Aug 2015 12:40:34 +0000 (+0200) Subject: Fixed bug #70198 Checking liveness does not work as expected X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=24f0fe6b1f53e2d610dc27c04b0c6cd9927f4d4a;p=php Fixed bug #70198 Checking liveness does not work as expected --- diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index 13ed703682..300a58e491 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -314,7 +314,17 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void if (sock->socket == -1) { alive = 0; } else if (php_pollfd_for(sock->socket, PHP_POLLREADABLE|POLLPRI, &tv) > 0) { - if (0 >= recv(sock->socket, &buf, sizeof(buf), MSG_PEEK) && php_socket_errno() != EWOULDBLOCK) { +#ifdef PHP_WIN32 + int ret; +#else + ssize_t ret; +#endif + int err; + + ret = recv(sock->socket, &buf, sizeof(buf), MSG_PEEK); + err = php_socket_errno(); + if (0 == ret || /* the counterpart did properly shutdown*/ + 0 > ret && err != EWOULDBLOCK && err != EAGAIN) { /* there was an unrecoverable error */ alive = 0; } }