Skip to content

Commit

Permalink
don't return -1 if the socket was closed (netdata#15771)
Browse files Browse the repository at this point in the history
  • Loading branch information
moonbreon committed Sep 8, 2023
1 parent 85e93d1 commit 43b1a2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions exporting/send_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
5 changes: 5 additions & 0 deletions libnetdata/socket/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 43b1a2e

Please sign in to comment.