Skip to content

Commit 797e30f

Browse files
committed
Fixed bug #70198 Checking liveness does not work as expected
1 parent 87db2e4 commit 797e30f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

main/streams/xp_socket.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,17 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void
293293
if (sock->socket == -1) {
294294
alive = 0;
295295
} else if (php_pollfd_for(sock->socket, PHP_POLLREADABLE|POLLPRI, &tv) > 0) {
296-
if (0 >= recv(sock->socket, &buf, sizeof(buf), MSG_PEEK) && php_socket_errno() != EWOULDBLOCK) {
296+
#ifdef PHP_WIN32
297+
int ret;
298+
#else
299+
ssize_t ret;
300+
#endif
301+
int err;
302+
303+
ret = recv(sock->socket, &buf, sizeof(buf), MSG_PEEK);
304+
err = php_socket_errno();
305+
if (0 == ret || /* the counterpart did properly shutdown*/
306+
0 > ret && err != EWOULDBLOCK && err != EAGAIN) { /* there was an unrecoverable error */
297307
alive = 0;
298308
}
299309
}

0 commit comments

Comments
 (0)