mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Avoid call to php_socket_errno() if possible (#13909)
This call is only necessary if ret < 0. Note that I also had to reoder the checks for EWOULDBLOCK, EMSGSIZE, EAGAIN to avoid a false positive GCC warning about a duplicate condition (EAGAIN == EWOULDBLOCK on my system).
This commit is contained in:
parent
9b5749a97e
commit
ae5220aed6
2 changed files with 16 additions and 8 deletions
|
@ -2577,13 +2577,17 @@ static int php_openssl_sockop_set_option(php_stream *stream, int option, int val
|
||||||
#else
|
#else
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
#endif
|
#endif
|
||||||
int err;
|
|
||||||
|
|
||||||
ret = recv(sslsock->s.socket, &buf, sizeof(buf), MSG_PEEK|MSG_DONTWAIT);
|
ret = recv(sslsock->s.socket, &buf, sizeof(buf), MSG_PEEK|MSG_DONTWAIT);
|
||||||
err = php_socket_errno();
|
if (0 == ret) {
|
||||||
if (0 == ret || /* the counterpart did properly shutdown */
|
/* the counterpart did properly shutdown */
|
||||||
(0 > ret && err != EWOULDBLOCK && err != EAGAIN && err != EMSGSIZE)) { /* there was an unrecoverable error */
|
|
||||||
alive = 0;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,13 +373,17 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void
|
||||||
#else
|
#else
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
#endif
|
#endif
|
||||||
int err;
|
|
||||||
|
|
||||||
ret = recv(sock->socket, &buf, sizeof(buf), MSG_PEEK|MSG_DONTWAIT);
|
ret = recv(sock->socket, &buf, sizeof(buf), MSG_PEEK|MSG_DONTWAIT);
|
||||||
err = php_socket_errno();
|
if (0 == ret) {
|
||||||
if (0 == ret || /* the counterpart did properly shutdown*/
|
/* the counterpart did properly shutdown */
|
||||||
(0 > ret && err != EWOULDBLOCK && err != EAGAIN && err != EMSGSIZE)) { /* there was an unrecoverable error */
|
|
||||||
alive = 0;
|
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;
|
return alive ? PHP_STREAM_OPTION_RETURN_OK : PHP_STREAM_OPTION_RETURN_ERR;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue