summaryrefslogtreecommitdiffstats
path: root/libnetdata/socket
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-06 16:11:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-06 16:11:34 +0000
commitd079b656b4719739b2247dcd9d46e9bec793095a (patch)
treed2c950c70a776bcf697c963151c5bd959f8a9f03 /libnetdata/socket
parentReleasing debian version 1.37.1-2. (diff)
downloadnetdata-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/security.c2
-rw-r--r--libnetdata/socket/socket.c37
-rw-r--r--libnetdata/socket/socket.h25
3 files changed, 37 insertions, 27 deletions
diff --git a/libnetdata/socket/security.c b/libnetdata/socket/security.c
index 88b3f6d9..7c509215 100644
--- a/libnetdata/socket/security.c
+++ b/libnetdata/socket/security.c
@@ -310,7 +310,7 @@ int security_process_accept(SSL *ssl,int msg) {
int counter = 0;
while ((err = ERR_get_error()) != 0) {
ERR_error_string_n(err, buf, sizeof(buf));
- info("%d SSL Handshake error (%s) on socket %d ", counter++, ERR_error_string((long)SSL_get_error(ssl, test), NULL), sock);
+ error("%d SSL Handshake error (%s) on socket %d", counter++, ERR_error_string((long)SSL_get_error(ssl, test), NULL), sock);
}
return NETDATA_SSL_NO_HANDSHAKE;
}
diff --git a/libnetdata/socket/socket.c b/libnetdata/socket/socket.c
index 40271b62..69124b94 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();
diff --git a/libnetdata/socket/socket.h b/libnetdata/socket/socket.h
index 28232427..9577453d 100644
--- a/libnetdata/socket/socket.h
+++ b/libnetdata/socket/socket.h
@@ -10,18 +10,18 @@
#endif
typedef enum web_client_acl {
- WEB_CLIENT_ACL_NONE = 0,
- WEB_CLIENT_ACL_NOCHECK = 0,
- WEB_CLIENT_ACL_DASHBOARD = 1 << 0,
- WEB_CLIENT_ACL_REGISTRY = 1 << 1,
- WEB_CLIENT_ACL_BADGE = 1 << 2,
- WEB_CLIENT_ACL_MGMT = 1 << 3,
- WEB_CLIENT_ACL_STREAMING = 1 << 4,
- WEB_CLIENT_ACL_NETDATACONF = 1 << 5,
- WEB_CLIENT_ACL_SSL_OPTIONAL = 1 << 6,
- WEB_CLIENT_ACL_SSL_FORCE = 1 << 7,
- WEB_CLIENT_ACL_SSL_DEFAULT = 1 << 8,
- WEB_CLIENT_ACL_ACLK = 1 << 9,
+ WEB_CLIENT_ACL_NONE = (0),
+ WEB_CLIENT_ACL_NOCHECK = (0),
+ WEB_CLIENT_ACL_DASHBOARD = (1 << 0),
+ WEB_CLIENT_ACL_REGISTRY = (1 << 1),
+ WEB_CLIENT_ACL_BADGE = (1 << 2),
+ WEB_CLIENT_ACL_MGMT = (1 << 3),
+ WEB_CLIENT_ACL_STREAMING = (1 << 4),
+ WEB_CLIENT_ACL_NETDATACONF = (1 << 5),
+ WEB_CLIENT_ACL_SSL_OPTIONAL = (1 << 6),
+ WEB_CLIENT_ACL_SSL_FORCE = (1 << 7),
+ WEB_CLIENT_ACL_SSL_DEFAULT = (1 << 8),
+ WEB_CLIENT_ACL_ACLK = (1 << 9),
} WEB_CLIENT_ACL;
#define WEB_CLIENT_ACL_ALL 0xFFFF
@@ -202,6 +202,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