From 2edd04a92edb4bbeca105dffa5367151fcb699d5 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 6 May 2016 15:40:50 +0100 Subject: [PATCH] [Rework] Separate method to close backend connections --- src/rspamd_proxy.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c index ef85728e3..d2c4ee3d4 100644 --- a/src/rspamd_proxy.c +++ b/src/rspamd_proxy.c @@ -441,14 +441,20 @@ init_rspamd_proxy (struct rspamd_config *cfg) return ctx; } +static void +proxy_session_close_connection (struct rspamd_proxy_backend_connection *conn) +{ + if (conn->backend_conn) { + rspamd_http_connection_unref (conn->backend_conn); + } + close (conn->backend_sock); +} + static void proxy_session_dtor (struct rspamd_proxy_session *session) { if (session->master_conn) { - if (session->master_conn->backend_conn) { - rspamd_http_connection_unref (session->master_conn->backend_conn); - } - close (session->master_conn->backend_sock); + proxy_session_close_connection (session->master_conn); } if (session->map && session->map_len) { @@ -682,6 +688,8 @@ proxy_client_finish_handler (struct rspamd_http_connection *conn, } } else { + proxy_session_close_connection (session->master_conn); + session->master_conn = NULL; REF_RELEASE (session); } -- 2.39.5