From 1af89c35663dd364c8d46523f0d71adc64f8bde4 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 14 Aug 2018 12:51:54 +0100 Subject: [Fix] Add fail-safety for destroying sessions --- src/libserver/events.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/libserver/events.c') diff --git a/src/libserver/events.c b/src/libserver/events.c index 9b0d049d4..f62005b96 100644 --- a/src/libserver/events.c +++ b/src/libserver/events.c @@ -172,6 +172,13 @@ rspamd_session_add_event (struct rspamd_async_session *session, g_assert_not_reached (); } + if (RSPAMD_SESSION_IS_DESTROYING (session)) { + msg_debug_session ("skip adding event subsystem: %s: session is destroying", + g_quark_to_string (subsystem)); + + return NULL; + } + new_event = rspamd_mempool_alloc (session->pool, sizeof (struct rspamd_async_event)); new_event->fin = fin; @@ -502,4 +509,12 @@ rspamd_session_mempool (struct rspamd_async_session *session) g_assert (session != NULL); return session->pool; +} + +gboolean +rspamd_session_is_destroying (struct rspamd_async_session *session) +{ + g_assert (session != NULL); + + return RSPAMD_SESSION_IS_DESTROYING (session); } \ No newline at end of file -- cgit v1.2.3