summaryrefslogtreecommitdiffstats
path: root/libnetdata/socket/socket.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-06 16:11:30 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-06 16:11:30 +0000
commitaa2fe8ccbfcb117efa207d10229eeeac5d0f97c7 (patch)
tree941cbdd387b41c1a81587c20a6df9f0e5e0ff7ab /libnetdata/socket/socket.c
parentAdding upstream version 1.37.1. (diff)
downloadnetdata-aa2fe8ccbfcb117efa207d10229eeeac5d0f97c7.tar.xz
netdata-aa2fe8ccbfcb117efa207d10229eeeac5d0f97c7.zip
Adding upstream version 1.38.0.upstream/1.38.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libnetdata/socket/socket.c')
-rw-r--r--libnetdata/socket/socket.c37
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();