diff options
author | moonbreon <yakoup46@gmail.com> | 2023-09-08 04:25:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-08 11:25:23 +0300 |
commit | 43b1a2e25ed1275ccd60e6c2c7eed550ee44adf7 (patch) | |
tree | 0b60544015d2f2c9bc056f7687fc5d2cb3413bd2 | |
parent | 85e93d18a8e57257220d24637505f90771563289 (diff) |
don't return `-1` if the socket was closed (#15771)
-rw-r--r-- | exporting/send_data.c | 2 | ||||
-rw-r--r-- | libnetdata/socket/security.c | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/exporting/send_data.c b/exporting/send_data.c index 6a38042deb..e8b8aaf60a 100644 --- a/exporting/send_data.c +++ b/exporting/send_data.c @@ -106,6 +106,8 @@ void simple_connector_receive_response(int *sock, struct instance *instance) // failed to receive data if (errno != EAGAIN && errno != EWOULDBLOCK) { netdata_log_error("EXPORTING: cannot receive data from '%s'.", instance->config.destination); + close(*sock); + *sock = -1; } } diff --git a/libnetdata/socket/security.c b/libnetdata/socket/security.c index c1bb763456..3a3a171e52 100644 --- a/libnetdata/socket/security.c +++ b/libnetdata/socket/security.c @@ -234,6 +234,11 @@ ssize_t netdata_ssl_read(NETDATA_SSL *ssl, void *buf, size_t num) { if(unlikely(bytes <= 0)) { int err = SSL_get_error(ssl->conn, bytes); + if (err == SSL_ERROR_ZERO_RETURN) { + ssl->ssl_errno = err; + return 0; + } + if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) { ssl->ssl_errno = err; errno = EWOULDBLOCK; |