summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-06-10 12:39:15 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-06-10 12:39:15 +0100
commitf2bf0f2db2f558584b632d92bb87e7028cb0dfad (patch)
tree1a911e14b2f3114991e0eb2ff7906873d48dc5f3
parentcf96ac1b6f787edd491c0291b5be1a9a3c7136f4 (diff)
downloadrspamd-f2bf0f2db2f558584b632d92bb87e7028cb0dfad.tar.gz
rspamd-f2bf0f2db2f558584b632d92bb87e7028cb0dfad.zip
[Fix] Fix processing of the watchers
-rw-r--r--src/libserver/events.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/src/libserver/events.c b/src/libserver/events.c
index d9030c5b3..4a7d5d634 100644
--- a/src/libserver/events.c
+++ b/src/libserver/events.c
@@ -147,17 +147,23 @@ rspamd_session_add_event (struct rspamd_async_session *session,
if (RSPAMD_SESSION_IS_WATCHING (session)) {
new->w = session->cur_watcher;
new->w->remain ++;
+ msg_debug_session ("added event: %p, pending %d events, "
+ "subsystem: %s, watcher: %d",
+ user_data,
+ g_hash_table_size (session->events),
+ g_quark_to_string (subsystem),
+ new->w->id);
}
else {
new->w = NULL;
+ msg_debug_session ("added event: %p, pending %d events, "
+ "subsystem: %s, no watcher!",
+ user_data,
+ g_hash_table_size (session->events),
+ g_quark_to_string (subsystem));
}
g_hash_table_insert (session->events, new, new);
-
- msg_debug_session ("added event: %p, pending %d events, subsystem: %s",
- user_data,
- g_hash_table_size (session->events),
- g_quark_to_string (subsystem));
}
static inline void
@@ -191,20 +197,29 @@ rspamd_session_remove_event (struct rspamd_async_session *session,
found_ev = g_hash_table_lookup (session->events, &search_ev);
g_assert (found_ev != NULL);
- msg_debug_session ("removed event: %p, subsystem: %s, pending %d events", ud,
- g_quark_to_string (found_ev->subsystem),
- g_hash_table_size (session->events));
/* Remove event */
fin (ud);
/* Call watcher if needed */
if (found_ev->w) {
+ msg_debug_session ("removed event: %p, subsystem: %s, "
+ "pending %d events, watcher: %d (%d pending)", ud,
+ g_quark_to_string (found_ev->subsystem),
+ g_hash_table_size (session->events),
+ found_ev->w->id, found_ev->w->remain);
+
if (found_ev->w->remain > 0) {
if (--found_ev->w->remain == 0) {
rspamd_session_call_watcher_stack (session, found_ev->w);
}
}
}
+ else {
+ msg_debug_session ("removed event: %p, subsystem: %s, "
+ "pending %d events, no watcher!", ud,
+ g_quark_to_string (found_ev->subsystem),
+ g_hash_table_size (session->events));
+ }
g_hash_table_remove (session->events, found_ev);
@@ -410,11 +425,12 @@ rspamd_session_watcher_pop (struct rspamd_async_session *session,
{
g_assert (session != NULL);
- if (w) {
+ if (w && w->remain > 0) {
msg_debug_session ("pop session, watcher: %d, %d events", w->id,
w->remain);
+ w->remain --;
- if (--w->remain == 0) {
+ if (w->remain == 0) {
rspamd_session_call_watcher_stack (session, w);
}
}
@@ -425,5 +441,10 @@ rspamd_session_get_watcher (struct rspamd_async_session *session)
{
g_assert (session != NULL);
- return session->cur_watcher;
+ if (RSPAMD_SESSION_IS_WATCHING (session)) {
+ return session->cur_watcher;
+ }
+ else {
+ return NULL;
+ }
}