diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-02-13 19:09:27 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-02-13 19:09:27 +0400 |
commit | 0d64c808b7310b6e233ec570649fbb281a3f2b13 (patch) | |
tree | bec667c9c350cc53dcd05e7779988486778c64c9 /src/events.c | |
parent | b5f2b43a8d1fc3361dc1665c62b2a44d66c01474 (diff) | |
download | rspamd-0d64c808b7310b6e233ec570649fbb281a3f2b13.tar.gz rspamd-0d64c808b7310b6e233ec570649fbb281a3f2b13.zip |
Add quarks to events to determine source of event inside rspamd.
Another try to fix threading.
Diffstat (limited to 'src/events.c')
-rw-r--r-- | src/events.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/events.c b/src/events.c index 98b492ffb..b658f48a9 100644 --- a/src/events.c +++ b/src/events.c @@ -87,7 +87,7 @@ new_async_session (memory_pool_t * pool, event_finalizer_t fin, } void -register_async_event (struct rspamd_async_session *session, event_finalizer_t fin, void *user_data, gboolean forced) +register_async_event (struct rspamd_async_session *session, event_finalizer_t fin, void *user_data, GQuark subsystem) { struct rspamd_async_event *new; @@ -99,32 +99,39 @@ register_async_event (struct rspamd_async_session *session, event_finalizer_t fi new = memory_pool_alloc (session->pool, sizeof (struct rspamd_async_event)); new->fin = fin; new->user_data = user_data; + new->subsystem = subsystem; g_hash_table_insert (session->events, new, new); #ifdef RSPAMD_EVENTS_DEBUG - msg_info ("added event: %p, pending %d events", user_data, g_hash_table_size (session->events)); + msg_info ("added event: %p, pending %d events, subsystem: %s", user_data, g_hash_table_size (session->events), + g_quark_to_string (subsystem)); #endif } void remove_normal_event (struct rspamd_async_session *session, event_finalizer_t fin, void *ud) { - struct rspamd_async_event search_ev; + struct rspamd_async_event search_ev, *found_ev; if (session == NULL) { msg_info ("session is NULL"); return; } + /* Search for event */ search_ev.fin = fin; search_ev.user_data = ud; - if (g_hash_table_remove (session->events, &search_ev)) { + if ((found_ev = g_hash_table_lookup (session->events, &search_ev)) != NULL) { + g_hash_table_remove (session->events, found_ev); +#ifdef RSPAMD_EVENTS_DEBUG + msg_info ("removed event: %p, subsystem: %s, pending %d events", ud, + g_quark_to_string (found_ev->subsystem), g_hash_table_size (session->events)); +#endif + /* Remove event */ fin (ud); } -#ifdef RSPAMD_EVENTS_DEBUG - msg_info ("removed event: %p, pending %d events", ud, g_hash_table_size (session->events)); -#endif + check_session_pending (session); } |