diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-02-01 18:32:31 +0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-01 18:32:31 +0600 |
commit | 41ee1140eb2069f5afb07cf28999f7e9d09d234d (patch) | |
tree | 882d3b37092cac8656760e701c23c6dd6bc87703 /src/libstat/backends/redis_backend.cxx | |
parent | 5124e5461402e20ab3b36a80fa13d271c9847e10 (diff) | |
parent | 500fac7fd7861f926cbe2735d43e1cfc9b9c7a9e (diff) | |
download | rspamd-41ee1140eb2069f5afb07cf28999f7e9d09d234d.tar.gz rspamd-41ee1140eb2069f5afb07cf28999f7e9d09d234d.zip |
Merge pull request #4805 from rspamd/vstakhov-fix-rspamadm-mime-stat
[Fix] Resolve issue with bayes stat in `rspamadm` mode
Diffstat (limited to 'src/libstat/backends/redis_backend.cxx')
-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); |