summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2015-08-11 14:40:34 +0200
committerAnatol Belski <ab@php.net>2015-08-11 14:40:34 +0200
commit24f0fe6b1f53e2d610dc27c04b0c6cd9927f4d4a (patch)
tree83afebf5a38329f49300385d046a4848fed96c25 /main
parentb0893344df1946c842d06a8d2c576abb4f7c78e7 (diff)
downloadphp-git-24f0fe6b1f53e2d610dc27c04b0c6cd9927f4d4a.tar.gz
Fixed bug #70198 Checking liveness does not work as expected
Diffstat (limited to 'main')
-rw-r--r--main/streams/xp_socket.c12
1 files changed, 11 insertions, 1 deletions
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;
}
}