diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-26 17:50:35 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-26 17:50:35 +0000 |
commit | ff74d742158c985d4e59655f6989e68a024122d7 (patch) | |
tree | f150883001b5766ff76eb6d60edfabaaa3abc313 | |
parent | 62c2acacbb8edf6cb58b16daaf98004d93711bd1 (diff) | |
download | rspamd-ff74d742158c985d4e59655f6989e68a024122d7.tar.gz rspamd-ff74d742158c985d4e59655f6989e68a024122d7.zip |
Implement forced timeout for delayed filters
Issue: #452
-rw-r--r-- | src/libserver/events.c | 17 | ||||
-rw-r--r-- | src/libserver/events.h | 5 | ||||
-rw-r--r-- | src/worker.c | 2 |
3 files changed, 21 insertions, 3 deletions
diff --git a/src/libserver/events.c b/src/libserver/events.c index d94149584..45ca50ce4 100644 --- a/src/libserver/events.c +++ b/src/libserver/events.c @@ -227,9 +227,7 @@ rspamd_session_destroy (struct rspamd_async_session *session) } session->flags |= RSPAMD_SESSION_FLAG_DESTROYING; - g_hash_table_foreach_remove (session->events, - rspamd_session_destroy_callback, - session); + rspamd_session_cleanup (session); if (session->cleanup != NULL) { session->cleanup (session->user_data); @@ -238,6 +236,19 @@ rspamd_session_destroy (struct rspamd_async_session *session) return TRUE; } +void +rspamd_session_cleanup (struct rspamd_async_session *session) +{ + if (session == NULL) { + msg_info_session ("session is NULL"); + return; + } + + g_hash_table_foreach_remove (session->events, + rspamd_session_destroy_callback, + session); +} + gboolean rspamd_session_pending (struct rspamd_async_session *session) { diff --git a/src/libserver/events.h b/src/libserver/events.h index 012629397..cd748be0a 100644 --- a/src/libserver/events.h +++ b/src/libserver/events.h @@ -76,6 +76,11 @@ void rspamd_session_remove_event (struct rspamd_async_session *session, gboolean rspamd_session_destroy (struct rspamd_async_session *session); /** + * Try to remove all events pending + */ +void rspamd_session_cleanup (struct rspamd_async_session *session); + +/** * Check session for events pending and call fin callback if no events are pending * @param session session object * @return TRUE if session has pending events diff --git a/src/worker.c b/src/worker.c index 2598be415..63cb778f4 100644 --- a/src/worker.c +++ b/src/worker.c @@ -129,7 +129,9 @@ rspamd_task_timeout (gint fd, short what, gpointer ud) if (!(task->processed_stages & RSPAMD_TASK_STAGE_FILTERS)) { msg_info_task ("processing of task timed out, forced processing"); task->processed_stages |= RSPAMD_TASK_STAGE_FILTERS; + rspamd_session_cleanup (task->s); rspamd_task_process (task, RSPAMD_TASK_PROCESS_ALL); + rspamd_session_pending (task->s); } } |