From 9959f9031e305e117c6b89671ac86c4e84135340 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 15 Oct 2014 14:35:20 +0100 Subject: [PATCH] Fix HTTP connection termination. If a remote side terminates a connection, then notify and destroy client as well. --- src/libutil/http.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libutil/http.c b/src/libutil/http.c index e78a798907..db48bd6de5 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -650,8 +650,8 @@ rspamd_http_write_helper (struct rspamd_http_connection *conn) call_finish_handler: if ((conn->opts & RSPAMD_HTTP_CLIENT_SIMPLE) == 0) { rspamd_http_connection_ref (conn); - conn->finish_handler (conn, priv->msg); conn->finished = TRUE; + conn->finish_handler (conn, priv->msg); rspamd_http_connection_unref (conn); } else { @@ -695,6 +695,8 @@ rspamd_http_event_handler (int fd, short what, gpointer ud) if (conn->finished) { REF_RELEASE (pbuf); rspamd_http_connection_unref (conn); + /* Double unref to avoid dangling connections */ + rspamd_http_connection_unref (conn); return; } else { -- 2.47.3