diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-02-01 11:49:07 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-02-01 11:50:05 +0000 |
commit | 500fac7fd7861f926cbe2735d43e1cfc9b9c7a9e (patch) | |
tree | a08b2a15f69525f7e85e5705542e4bc9c8ce2364 /src/libstat | |
parent | 9259503f04a54fdb87ce972b162ed9950a164649 (diff) | |
download | rspamd-500fac7fd7861f926cbe2735d43e1cfc9b9c7a9e.tar.gz rspamd-500fac7fd7861f926cbe2735d43e1cfc9b9c7a9e.zip |
[Fix] Resolve issue with bayes stat in `rspamadm` mode
Diffstat (limited to 'src/libstat')
-rw-r--r-- | src/libstat/backends/redis_backend.cxx | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/libstat/backends/redis_backend.cxx b/src/libstat/backends/redis_backend.cxx index cd0c37965..14e821029 100644 --- a/src/libstat/backends/redis_backend.cxx +++ b/src/libstat/backends/redis_backend.cxx @@ -542,9 +542,16 @@ rspamd_redis_init(struct rspamd_stat_ctx *ctx, ucl_object_push_lua(L, st->stcf->opts, false); lua_pushstring(L, backend->stcf->symbol); lua_pushboolean(L, backend->stcf->is_spam); - auto **pev_base = (struct ev_loop **) lua_newuserdata(L, sizeof(struct ev_loop *)); - *pev_base = ctx->event_loop; - rspamd_lua_setclass(L, "rspamd{ev_base}", -1); + + /* Push event loop if there is one available (e.g. we are not in rspamadm mode) */ + if (ctx->event_loop) { + auto **pev_base = (struct ev_loop **) lua_newuserdata(L, sizeof(struct ev_loop *)); + *pev_base = ctx->event_loop; + rspamd_lua_setclass(L, "rspamd{ev_base}", -1); + } + else { + lua_pushnil(L); + } /* Store backend in random cookie */ char *cookie = (char *) rspamd_mempool_alloc(cfg->cfg_pool, 16); |