diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-06 16:11:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-06 16:11:34 +0000 |
commit | d079b656b4719739b2247dcd9d46e9bec793095a (patch) | |
tree | d2c950c70a776bcf697c963151c5bd959f8a9f03 /libnetdata/socket/socket.c | |
parent | Releasing debian version 1.37.1-2. (diff) | |
download | netdata-d079b656b4719739b2247dcd9d46e9bec793095a.tar.xz netdata-d079b656b4719739b2247dcd9d46e9bec793095a.zip |
Merging upstream version 1.38.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | libnetdata/socket/socket.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/libnetdata/socket/socket.c b/libnetdata/socket/socket.c index 40271b623..69124b949 100644 --- a/libnetdata/socket/socket.c +++ b/libnetdata/socket/socket.c @@ -926,13 +926,17 @@ ssize_t netdata_ssl_read(SSL *ssl, void *buf, size_t num) { int bytes, err, retries = 0; //do { - bytes = SSL_read(ssl, buf, (int)num); - err = SSL_get_error(ssl, bytes); - retries++; - //} while (bytes <= 0 && (err == SSL_ERROR_WANT_READ)); + bytes = SSL_read(ssl, buf, (int)num); + err = SSL_get_error(ssl, bytes); + retries++; + //} while (bytes <= 0 && err == SSL_ERROR_WANT_READ); - if(unlikely(bytes <= 0)) - error("SSL_read() returned %d bytes, SSL error %d", bytes, err); + if(unlikely(bytes <= 0)) { + if (err == SSL_ERROR_WANT_WRITE || err == SSL_ERROR_WANT_READ) { + bytes = 0; + } else + error("SSL_write() returned %d bytes, SSL error %d", bytes, err); + } if(retries > 1) error_limit(&erl, "SSL_read() retried %d times", retries); @@ -947,17 +951,21 @@ ssize_t netdata_ssl_write(SSL *ssl, const void *buf, size_t num) { size_t total = 0; //do { - bytes = SSL_write(ssl, (uint8_t *)buf + total, (int)(num - total)); - err = SSL_get_error(ssl, bytes); - retries++; + bytes = SSL_write(ssl, (uint8_t *)buf + total, (int)(num - total)); + err = SSL_get_error(ssl, bytes); + retries++; - if(bytes > 0) - total += bytes; + if(bytes > 0) + total += bytes; //} while ((bytes <= 0 && (err == SSL_ERROR_WANT_WRITE)) || (bytes > 0 && total < num)); - if(unlikely(bytes <= 0)) - error("SSL_write() returned %d bytes, SSL error %d", bytes, err); + if(unlikely(bytes <= 0)) { + if (err == SSL_ERROR_WANT_WRITE || err == SSL_ERROR_WANT_READ) { + bytes = 0; + } else + error("SSL_write() returned %d bytes, SSL error %d", bytes, err); + } if(retries > 1) error_limit(&erl, "SSL_write() retried %d times", retries); @@ -1633,6 +1641,7 @@ void poll_events(LISTEN_SOCKETS *sockets , int (*rcv_callback)(POLLINFO * /*pi*/, short int * /*events*/) , int (*snd_callback)(POLLINFO * /*pi*/, short int * /*events*/) , void (*tmr_callback)(void * /*timer_data*/) + , bool (*check_to_stop_callback)(void) , SIMPLE_PATTERN *access_list , int allow_dns , void *data @@ -1715,7 +1724,7 @@ void poll_events(LISTEN_SOCKETS *sockets netdata_thread_cleanup_push(poll_events_cleanup, &p); - while(!netdata_exit) { + while(!check_to_stop_callback()) { if(unlikely(timer_usec)) { now_usec = now_boottime_usec(); |