mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
main: pack _php_netstream_data_t and use bool instead of int type (#19331)
Fix use sites at the same time
This commit is contained in:
parent
0591defd6f
commit
dad28a30f3
4 changed files with 24 additions and 24 deletions
|
@ -237,7 +237,7 @@ static int php_openssl_handle_ssl_error(php_stream *stream, int nr_bytes, bool i
|
|||
char esbuf[512];
|
||||
smart_str ebuf = {0};
|
||||
unsigned long ecode;
|
||||
int retry = 1;
|
||||
bool retry = true;
|
||||
|
||||
switch(err) {
|
||||
case SSL_ERROR_ZERO_RETURN:
|
||||
|
@ -249,7 +249,7 @@ static int php_openssl_handle_ssl_error(php_stream *stream, int nr_bytes, bool i
|
|||
/* re-negotiation, or perhaps the SSL layer needs more
|
||||
* packets: retry in next iteration */
|
||||
errno = EAGAIN;
|
||||
retry = is_init ? 1 : sslsock->s.is_blocked;
|
||||
retry = is_init ? true : sslsock->s.is_blocked;
|
||||
break;
|
||||
case SSL_ERROR_SYSCALL:
|
||||
if (ERR_peek_error() == 0) {
|
||||
|
@ -1806,7 +1806,7 @@ static int php_openssl_enable_crypto(php_stream *stream,
|
|||
|
||||
if (cparam->inputs.activate && !sslsock->ssl_active) {
|
||||
struct timeval start_time, *timeout;
|
||||
int blocked = sslsock->s.is_blocked, has_timeout = 0;
|
||||
bool blocked = sslsock->s.is_blocked, has_timeout = false;
|
||||
|
||||
#ifdef HAVE_TLS_SNI
|
||||
if (sslsock->is_client) {
|
||||
|
@ -1946,8 +1946,8 @@ static ssize_t php_openssl_sockop_io(int read, php_stream *stream, char *buf, si
|
|||
int retry = 1;
|
||||
struct timeval start_time;
|
||||
struct timeval *timeout = NULL;
|
||||
int began_blocked = sslsock->s.is_blocked;
|
||||
int has_timeout = 0;
|
||||
bool began_blocked = sslsock->s.is_blocked;
|
||||
bool has_timeout = false;
|
||||
int nr_bytes = 0;
|
||||
|
||||
/* prevent overflow in openssl */
|
||||
|
@ -1965,7 +1965,7 @@ static ssize_t php_openssl_sockop_io(int read, php_stream *stream, char *buf, si
|
|||
}
|
||||
|
||||
if (!sslsock->s.is_blocked && timeout && (timeout->tv_sec > 0 || (timeout->tv_sec == 0 && timeout->tv_usec))) {
|
||||
has_timeout = 1;
|
||||
has_timeout = true;
|
||||
/* gettimeofday is not monotonic; using it here is not strictly correct */
|
||||
gettimeofday(&start_time, NULL);
|
||||
}
|
||||
|
@ -1987,7 +1987,7 @@ static ssize_t php_openssl_sockop_io(int read, php_stream *stream, char *buf, si
|
|||
if (began_blocked) {
|
||||
php_openssl_set_blocking(sslsock, 1);
|
||||
}
|
||||
sslsock->s.timeout_event = 1;
|
||||
sslsock->s.timeout_event = true;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -2248,7 +2248,7 @@ static inline int php_openssl_tcp_sockop_accept(php_stream *stream, php_openssl_
|
|||
clisockdata->s.socket = clisock;
|
||||
#ifdef __linux__
|
||||
/* O_NONBLOCK is not inherited on Linux */
|
||||
clisockdata->s.is_blocked = 1;
|
||||
clisockdata->s.is_blocked = true;
|
||||
#endif
|
||||
|
||||
xparam->outputs.client = php_stream_alloc_rel(stream->ops, clisockdata, NULL, "r+");
|
||||
|
@ -2379,8 +2379,8 @@ static int php_openssl_sockop_set_option(php_stream *stream, int option, int val
|
|||
int retry = 1;
|
||||
struct timeval start_time;
|
||||
struct timeval *timeout = NULL;
|
||||
int began_blocked = sslsock->s.is_blocked;
|
||||
int has_timeout = 0;
|
||||
bool began_blocked = sslsock->s.is_blocked;
|
||||
bool has_timeout = false;
|
||||
|
||||
/* never use a timeout with non-blocking sockets */
|
||||
if (began_blocked) {
|
||||
|
@ -2392,7 +2392,7 @@ static int php_openssl_sockop_set_option(php_stream *stream, int option, int val
|
|||
}
|
||||
|
||||
if (!sslsock->s.is_blocked && timeout && (timeout->tv_sec > 0 || (timeout->tv_sec == 0 && timeout->tv_usec))) {
|
||||
has_timeout = 1;
|
||||
has_timeout = true;
|
||||
/* gettimeofday is not monotonic; using it here is not strictly correct */
|
||||
gettimeofday(&start_time, NULL);
|
||||
}
|
||||
|
@ -2414,7 +2414,7 @@ static int php_openssl_sockop_set_option(php_stream *stream, int option, int val
|
|||
if (began_blocked) {
|
||||
php_openssl_set_blocking(sslsock, 1);
|
||||
}
|
||||
sslsock->s.timeout_event = 1;
|
||||
sslsock->s.timeout_event = true;
|
||||
return PHP_STREAM_OPTION_RETURN_ERR;
|
||||
}
|
||||
}
|
||||
|
@ -2438,7 +2438,7 @@ static int php_openssl_sockop_set_option(php_stream *stream, int option, int val
|
|||
}
|
||||
|
||||
/* Don't loop indefinitely in non-blocking mode if no data is available */
|
||||
if (began_blocked == 0 || !has_timeout) {
|
||||
if (!began_blocked || !has_timeout) {
|
||||
alive = retry;
|
||||
break;
|
||||
}
|
||||
|
@ -2668,7 +2668,7 @@ php_stream *php_openssl_ssl_socket_factory(const char *proto, size_t protolen,
|
|||
sslsock = pemalloc(sizeof(php_openssl_netstream_data_t), persistent_id ? 1 : 0);
|
||||
memset(sslsock, 0, sizeof(*sslsock));
|
||||
|
||||
sslsock->s.is_blocked = 1;
|
||||
sslsock->s.is_blocked = true;
|
||||
/* this timeout is used by standard stream funcs, therefore it should use the default value */
|
||||
#ifdef _WIN32
|
||||
sslsock->s.timeout.tv_sec = (long)FG(default_socket_timeout);
|
||||
|
|
|
@ -1109,7 +1109,7 @@ PHPAPI php_stream *_php_stream_sock_open_from_socket(php_socket_t socket, const
|
|||
sock = pemalloc(sizeof(php_netstream_data_t), persistent_id ? 1 : 0);
|
||||
memset(sock, 0, sizeof(php_netstream_data_t));
|
||||
|
||||
sock->is_blocked = 1;
|
||||
sock->is_blocked = true;
|
||||
sock->timeout.tv_sec = FG(default_socket_timeout);
|
||||
sock->timeout.tv_usec = 0;
|
||||
sock->socket = socket;
|
||||
|
|
|
@ -313,9 +313,9 @@ END_EXTERN_C()
|
|||
|
||||
struct _php_netstream_data_t {
|
||||
php_socket_t socket;
|
||||
char is_blocked;
|
||||
bool is_blocked;
|
||||
bool timeout_event;
|
||||
struct timeval timeout;
|
||||
char timeout_event;
|
||||
size_t ownsize;
|
||||
};
|
||||
typedef struct _php_netstream_data_t php_netstream_data_t;
|
||||
|
|
|
@ -80,13 +80,13 @@ retry:
|
|||
if (sock->is_blocked) {
|
||||
int retval;
|
||||
|
||||
sock->timeout_event = 0;
|
||||
sock->timeout_event = false;
|
||||
|
||||
do {
|
||||
retval = php_pollfd_for(sock->socket, POLLOUT, ptimeout);
|
||||
|
||||
if (retval == 0) {
|
||||
sock->timeout_event = 1;
|
||||
sock->timeout_event = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ static void php_sock_stream_wait_for_data(php_stream *stream, php_netstream_data
|
|||
return;
|
||||
}
|
||||
|
||||
sock->timeout_event = 0;
|
||||
sock->timeout_event = false;
|
||||
|
||||
if (has_buffered_data) {
|
||||
/* If there is already buffered data, use no timeout. */
|
||||
|
@ -146,7 +146,7 @@ static void php_sock_stream_wait_for_data(php_stream *stream, php_netstream_data
|
|||
retval = php_pollfd_for(sock->socket, PHP_POLLREADABLE, ptimeout);
|
||||
|
||||
if (retval == 0)
|
||||
sock->timeout_event = 1;
|
||||
sock->timeout_event = true;
|
||||
|
||||
if (retval >= 0)
|
||||
break;
|
||||
|
@ -399,7 +399,7 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void
|
|||
|
||||
case PHP_STREAM_OPTION_READ_TIMEOUT:
|
||||
sock->timeout = *(struct timeval*)ptrparam;
|
||||
sock->timeout_event = 0;
|
||||
sock->timeout_event = false;
|
||||
return PHP_STREAM_OPTION_RETURN_OK;
|
||||
|
||||
case PHP_STREAM_OPTION_META_DATA_API:
|
||||
|
@ -885,7 +885,7 @@ static inline int php_tcp_sockop_accept(php_stream *stream, php_netstream_data_t
|
|||
clisockdata->socket = clisock;
|
||||
#ifdef __linux__
|
||||
/* O_NONBLOCK is not inherited on Linux */
|
||||
clisockdata->is_blocked = 1;
|
||||
clisockdata->is_blocked = true;
|
||||
#endif
|
||||
|
||||
xparam->outputs.client = php_stream_alloc_rel(stream->ops, clisockdata, NULL, "r+");
|
||||
|
@ -963,7 +963,7 @@ PHPAPI php_stream *php_stream_generic_socket_factory(const char *proto, size_t p
|
|||
sock = pemalloc(sizeof(php_netstream_data_t), persistent_id ? 1 : 0);
|
||||
memset(sock, 0, sizeof(php_netstream_data_t));
|
||||
|
||||
sock->is_blocked = 1;
|
||||
sock->is_blocked = true;
|
||||
sock->timeout.tv_sec = FG(default_socket_timeout);
|
||||
sock->timeout.tv_usec = 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue