local function stat_handler(opts)
load_config(opts)
rspamd_url.init(rspamd_config:get_tld_path())
+ rspamd_config:init_subsystem('langdet,stat') -- Needed to gen stat tokens
local task = load_task(opts)
if opts.meta then
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);
else if (strcmp (parts[i], "langdet") == 0) {
cfg->lang_det = rspamd_language_detector_init (cfg);
}
+ else if (strcmp (parts[i], "stat") == 0) {
+ rspamd_stat_init (cfg, NULL);
+ }
+ else {
+ return luaL_error (L, "invalid param: %s", parts[i]);
+ }
}
}
else {