aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstat
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-06-19 16:17:09 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-06-19 16:17:09 +0100
commitcd90ae359bbfacd6d0f15bf701e35ee6c9ed54eb (patch)
treedb230ea90da81a2a3d58fb674af34d7cf35676a3 /src/libstat
parent52a9a2eed69bed33764a2eb66715711ea660fbeb (diff)
downloadrspamd-cd90ae359bbfacd6d0f15bf701e35ee6c9ed54eb.tar.gz
rspamd-cd90ae359bbfacd6d0f15bf701e35ee6c9ed54eb.zip
[Minor] Allow to initialise stat ctx via Lua API
Diffstat (limited to 'src/libstat')
-rw-r--r--src/libstat/stat_config.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/libstat/stat_config.c b/src/libstat/stat_config.c
index f5483b3ca..904be726d 100644
--- a/src/libstat/stat_config.c
+++ b/src/libstat/stat_config.c
@@ -475,17 +475,23 @@ rspamd_stat_ctx_register_async (rspamd_stat_async_handler handler,
elt->ud = d;
elt->timeout = timeout;
/* Enabled by default */
- elt->enabled = TRUE;
-
- event_set (&elt->timer_ev, -1, EV_TIMEOUT, rspamd_async_elt_on_timer, elt);
- event_base_set (st_ctx->ev_base, &elt->timer_ev);
- /*
- * First we set timeval to zero as we want cb to be executed as
- * fast as possible
- */
- elt->tv.tv_sec = 0;
- elt->tv.tv_usec = 0;
- event_add (&elt->timer_ev, &elt->tv);
+
+
+ if (st_ctx->ev_base) {
+ elt->enabled = TRUE;
+ event_set (&elt->timer_ev, -1, EV_TIMEOUT, rspamd_async_elt_on_timer, elt);
+ event_base_set (st_ctx->ev_base, &elt->timer_ev);
+ /*
+ * First we set timeval to zero as we want cb to be executed as
+ * fast as possible
+ */
+ elt->tv.tv_sec = 0;
+ elt->tv.tv_usec = 0;
+ event_add (&elt->timer_ev, &elt->tv);
+ }
+ else {
+ elt->enabled = FALSE;
+ }
g_queue_push_tail (st_ctx->async_elts, elt);