From: Vsevolod Stakhov Date: Tue, 7 Dec 2021 18:47:35 +0000 (+0000) Subject: [Minor] Try to fix keepalive for SSL connections X-Git-Tag: 3.2~186 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fe5a7f1829f106b5ca9a901121ea9cc04dab3df6;p=rspamd.git [Minor] Try to fix keepalive for SSL connections --- diff --git a/src/libserver/http/http_connection.c b/src/libserver/http/http_connection.c index e3e32eef8..0a5dee754 100644 --- a/src/libserver/http/http_connection.c +++ b/src/libserver/http/http_connection.c @@ -2303,29 +2303,26 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn return FALSE; } else { - if (priv->ssl) { - /* Cleanup the existing connection */ - rspamd_ssl_connection_free (priv->ssl); - } - - priv->ssl = rspamd_ssl_connection_new (ssl_ctx, priv->ctx->event_loop, - !(msg->flags & RSPAMD_HTTP_FLAG_SSL_NOVERIFY), - conn->log_tag); - g_assert (priv->ssl != NULL); + if (!priv->ssl) { + priv->ssl = rspamd_ssl_connection_new (ssl_ctx, priv->ctx->event_loop, + !(msg->flags & RSPAMD_HTTP_FLAG_SSL_NOVERIFY), + conn->log_tag); + g_assert (priv->ssl != NULL); - if (!rspamd_ssl_connect_fd (priv->ssl, conn->fd, host, &priv->ev, - priv->timeout, rspamd_http_event_handler, - rspamd_http_ssl_err_handler, conn)) { + if (!rspamd_ssl_connect_fd (priv->ssl, conn->fd, host, &priv->ev, + priv->timeout, rspamd_http_event_handler, + rspamd_http_ssl_err_handler, conn)) { - err = g_error_new (HTTP_ERROR, 400, - "ssl connection error: ssl error=%s, errno=%s", - ERR_error_string (ERR_get_error (), NULL), - strerror (errno)); - rspamd_http_connection_ref (conn); - conn->error_handler (conn, err); - rspamd_http_connection_unref (conn); - g_error_free (err); - return FALSE; + err = g_error_new (HTTP_ERROR, 400, + "ssl connection error: ssl error=%s, errno=%s", + ERR_error_string (ERR_get_error (), NULL), + strerror (errno)); + rspamd_http_connection_ref (conn); + conn->error_handler (conn, err); + rspamd_http_connection_unref (conn); + g_error_free (err); + return FALSE; + } } } }