diff --git a/src/rest_client.c b/src/rest_client.c index a85ebf8..478ee9b 100644 --- a/src/rest_client.c +++ b/src/rest_client.c @@ -205,6 +205,9 @@ static bool do_signed_request(rest_conn_t *rc, if (n <= 0) { int err = SSL_get_error(rc->ssl, n); if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) continue; + /* Connection dead — tear down so next call reconnects */ + SSL_free(rc->ssl); rc->ssl = NULL; + close(rc->fd); rc->fd = -1; break; } total += n;