diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-06-10 13:11:31 -0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-06-10 13:11:31 -0400 |
commit | fef4d3d8361893b6d49bafa7e0e524dcb110fdab (patch) | |
tree | 47ea54d5794f73c09cbeb0d6bf6768706931a1bb /src/libserver/events.c | |
parent | 861f1989d3dced229f77f191cc2db85771c3e023 (diff) | |
download | rspamd-fef4d3d8361893b6d49bafa7e0e524dcb110fdab.tar.gz rspamd-fef4d3d8361893b6d49bafa7e0e524dcb110fdab.zip |
Extend watchers functionality.
It is now possible to add fake watcher events that delays guarded events
untill it is really completed.
Diffstat (limited to 'src/libserver/events.c')
-rw-r--r-- | src/libserver/events.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/libserver/events.c b/src/libserver/events.c index bd46f1686..571347288 100644 --- a/src/libserver/events.c +++ b/src/libserver/events.c @@ -291,3 +291,34 @@ rspamd_session_events_pending (struct rspamd_async_session *session) return g_hash_table_size (session->events); } + +void +rspamd_session_watcher_push (struct rspamd_async_session *s) +{ + g_assert (s != NULL); + + if (s->cur_watcher) { + s->cur_watcher->remain ++; + } +} + +void +rspamd_session_watcher_pop (struct rspamd_async_session *s, + struct rspamd_async_watcher *w) +{ + g_assert (s != NULL); + + if (w) { + if (--w->remain == 0) { + w->cb (s->user_data, w->ud); + } + } +} + +struct rspamd_async_watcher* +rspamd_session_get_watcher (struct rspamd_async_session *s) +{ + g_assert (s != NULL); + + return s->cur_watcher; +} |