Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions ext/openssl/xp_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2577,13 +2577,17 @@ static int php_openssl_sockop_set_option(php_stream *stream, int option, int val
#else
ssize_t ret;
#endif
int err;

ret = recv(sslsock->s.socket, &buf, sizeof(buf), MSG_PEEK|MSG_DONTWAIT);
err = php_socket_errno();
if (0 == ret || /* the counterpart did properly shutdown */
(0 > ret && err != EWOULDBLOCK && err != EAGAIN && err != EMSGSIZE)) { /* there was an unrecoverable error */
if (0 == ret) {
/* the counterpart did properly shutdown */
alive = 0;
} else if (0 > ret) {
int err = php_socket_errno();
if (err != EWOULDBLOCK && err != EMSGSIZE && err != EAGAIN) {
/* there was an unrecoverable error */
alive = 0;
}
}
}
}
Expand Down
12 changes: 8 additions & 4 deletions main/streams/xp_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,17 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void
#else
ssize_t ret;
#endif
int err;

ret = recv(sock->socket, &buf, sizeof(buf), MSG_PEEK|MSG_DONTWAIT);
err = php_socket_errno();
if (0 == ret || /* the counterpart did properly shutdown*/
(0 > ret && err != EWOULDBLOCK && err != EAGAIN && err != EMSGSIZE)) { /* there was an unrecoverable error */
if (0 == ret) {
/* the counterpart did properly shutdown */
alive = 0;
} else if (0 > ret) {
int err = php_socket_errno();
if (err != EWOULDBLOCK && err != EMSGSIZE && err != EAGAIN) {
/* there was an unrecoverable error */
alive = 0;
}
}
}
return alive ? PHP_STREAM_OPTION_RETURN_OK : PHP_STREAM_OPTION_RETURN_ERR;
Expand Down