diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-09-28 18:10:57 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-09-28 18:10:57 +0100 |
commit | 0e80857cdb12d45f42c3f18263c4ddee263326ad (patch) | |
tree | 20cf4ba3777b5a235a29e5a0614cd5e71fa69edd | |
parent | c4265b7a25f438c8c9fa1c761d8b8bd2017977e2 (diff) | |
download | rspamd-0e80857cdb12d45f42c3f18263c4ddee263326ad.tar.gz rspamd-0e80857cdb12d45f42c3f18263c4ddee263326ad.zip |
[Fix] Try to fix watchers chaining
-rw-r--r-- | src/libserver/events.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/libserver/events.c b/src/libserver/events.c index 9563753e0..325da4452 100644 --- a/src/libserver/events.c +++ b/src/libserver/events.c @@ -395,12 +395,25 @@ rspamd_session_watch_start (struct rspamd_async_session *session, if (session->cur_watcher == NULL) { session->cur_watcher = rspamd_mempool_alloc0 (session->pool, sizeof (*session->cur_watcher)); - } - st_elt = rspamd_mempool_alloc (session->pool, sizeof (*st_elt)); - st_elt->cb = cb; - st_elt->ud = ud; - LL_PREPEND (session->cur_watcher->st, st_elt); + st_elt = rspamd_mempool_alloc (session->pool, sizeof (*st_elt)); + st_elt->cb = cb; + st_elt->ud = ud; + LL_PREPEND (session->cur_watcher->st, st_elt); + } + else { + if (session->cur_watcher->st) { + /* Reuse the existing (empty) watcher */ + session->cur_watcher->st->cb = cb; + session->cur_watcher->st->ud = ud; + } + else { + st_elt = rspamd_mempool_alloc (session->pool, sizeof (*st_elt)); + st_elt->cb = cb; + st_elt->ud = ud; + LL_PREPEND (session->cur_watcher->st, st_elt); + } + } session->cur_watcher->id = id; session->flags |= RSPAMD_SESSION_FLAG_WATCHING; |