diff options
author | Mikhail Galanin <mgalanin@mimecast.com> | 2018-09-10 15:21:40 +0100 |
---|---|---|
committer | Mikhail Galanin <mgalanin@mimecast.com> | 2018-09-10 15:21:40 +0100 |
commit | 5a7984802bc78cbc9424a0a13d6ab95596391e91 (patch) | |
tree | b55b753c82d522fb39914550087549ecb580613e /src/libserver | |
parent | a77f6d5515077c0b6912ce957d7c53bf0c526a58 (diff) | |
parent | d45ec6978fd0a19f172f6a8ead445ba30fc35467 (diff) | |
download | rspamd-5a7984802bc78cbc9424a0a13d6ab95596391e91.tar.gz rspamd-5a7984802bc78cbc9424a0a13d6ab95596391e91.zip |
Merge branch 'master' into redis-coroutines
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/dns.c | 2 | ||||
-rw-r--r-- | src/libserver/events.c | 18 | ||||
-rw-r--r-- | src/libserver/events.h | 2 |
3 files changed, 14 insertions, 8 deletions
diff --git a/src/libserver/dns.c b/src/libserver/dns.c index fbf37363a..5ac215ff7 100644 --- a/src/libserver/dns.c +++ b/src/libserver/dns.c @@ -122,7 +122,7 @@ make_dns_request (struct rspamd_dns_resolver *resolver, return FALSE; } - if (session && rspamd_session_is_destroying (session)) { + if (session && rspamd_session_blocked (session)) { return FALSE; } diff --git a/src/libserver/events.c b/src/libserver/events.c index c23c90328..a15338e7a 100644 --- a/src/libserver/events.c +++ b/src/libserver/events.c @@ -21,9 +21,10 @@ #define RSPAMD_SESSION_FLAG_WATCHING (1 << 0) #define RSPAMD_SESSION_FLAG_DESTROYING (1 << 1) +#define RSPAMD_SESSION_FLAG_CLEANUP (1 << 2) #define RSPAMD_SESSION_IS_WATCHING(s) ((s)->flags & RSPAMD_SESSION_FLAG_WATCHING) -#define RSPAMD_SESSION_IS_DESTROYING(s) ((s)->flags & RSPAMD_SESSION_FLAG_DESTROYING) +#define RSPAMD_SESSION_CAN_ADD_EVENT(s) (!((s)->flags & (RSPAMD_SESSION_FLAG_DESTROYING|RSPAMD_SESSION_FLAG_CLEANUP))) #define msg_err_session(...) rspamd_default_log_function(G_LOG_LEVEL_CRITICAL, \ "events", session->pool->tag.uid, \ @@ -172,8 +173,9 @@ 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", + if (!RSPAMD_SESSION_CAN_ADD_EVENT (session)) { + msg_debug_session ("skip adding event subsystem: %s: " + "session is destroying/cleaning", g_quark_to_string (subsystem)); return NULL; @@ -293,7 +295,7 @@ rspamd_session_destroy (struct rspamd_async_session *session) return FALSE; } - if (!(session->flags & RSPAMD_SESSION_FLAG_DESTROYING)) { + if (!rspamd_session_blocked (session)) { session->flags |= RSPAMD_SESSION_FLAG_DESTROYING; rspamd_session_cleanup (session); @@ -315,6 +317,8 @@ rspamd_session_cleanup (struct rspamd_async_session *session) return; } + session->flags |= RSPAMD_SESSION_FLAG_CLEANUP; + kh_foreach_key (session->events, ev, { /* Call event's finalizer */ msg_debug_session ("removed event on destroy: %p, subsystem: %s", @@ -327,6 +331,8 @@ rspamd_session_cleanup (struct rspamd_async_session *session) }); kh_clear (rspamd_events_hash, session->events); + + session->flags &= ~RSPAMD_SESSION_FLAG_CLEANUP; } gboolean @@ -509,9 +515,9 @@ rspamd_session_mempool (struct rspamd_async_session *session) } gboolean -rspamd_session_is_destroying (struct rspamd_async_session *session) +rspamd_session_blocked (struct rspamd_async_session *session) { g_assert (session != NULL); - return RSPAMD_SESSION_IS_DESTROYING (session); + return !RSPAMD_SESSION_CAN_ADD_EVENT (session); }
\ No newline at end of file diff --git a/src/libserver/events.h b/src/libserver/events.h index 10ccb8d1d..f7eeae9d0 100644 --- a/src/libserver/events.h +++ b/src/libserver/events.h @@ -153,6 +153,6 @@ struct rspamd_async_watcher* rspamd_session_get_watcher ( * @param s * @return */ -gboolean rspamd_session_is_destroying (struct rspamd_async_session *s); +gboolean rspamd_session_blocked (struct rspamd_async_session *s); #endif /* RSPAMD_EVENTS_H */ |