aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/controller.c2
-rw-r--r--src/libstat/stat_api.h3
-rw-r--r--src/libstat/stat_config.c4
-rw-r--r--src/libstat/stat_internal.h2
-rw-r--r--src/worker.c2
-rw-r--r--test/rspamd_test_suite.c2
6 files changed, 9 insertions, 6 deletions
diff --git a/src/controller.c b/src/controller.c
index 0a359a9a6..e5b06c2db 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -2561,7 +2561,7 @@ start_controller_worker (struct rspamd_worker *worker)
/* Maps events */
rspamd_map_watch (worker->srv->cfg, ctx->ev_base);
rspamd_symbols_cache_start_refresh (worker->srv->cfg->cache, ctx->ev_base);
- rspamd_stat_init (worker->srv->cfg);
+ rspamd_stat_init (worker->srv->cfg, ctx->ev_base);
event_base_loop (ctx->ev_base, 0);
rspamd_worker_block_signals ();
diff --git a/src/libstat/stat_api.h b/src/libstat/stat_api.h
index 1cdd2f029..a63ee3734 100644
--- a/src/libstat/stat_api.h
+++ b/src/libstat/stat_api.h
@@ -26,6 +26,7 @@
#include "config.h"
#include "task.h"
#include <lua.h>
+#include <event.h>
/**
* @file stat_api.h
@@ -48,7 +49,7 @@ typedef enum rspamd_stat_result_e {
* Initialise statistics modules
* @param cfg
*/
-void rspamd_stat_init (struct rspamd_config *cfg);
+void rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base);
/**
* Finalize statistics
diff --git a/src/libstat/stat_config.c b/src/libstat/stat_config.c
index 1f16a98de..bca4cd954 100644
--- a/src/libstat/stat_config.c
+++ b/src/libstat/stat_config.c
@@ -84,7 +84,7 @@ static struct rspamd_stat_cache stat_caches[] = {
};
void
-rspamd_stat_init (struct rspamd_config *cfg)
+rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base)
{
GList *cur, *curst;
struct rspamd_classifier_config *clf;
@@ -110,6 +110,7 @@ rspamd_stat_init (struct rspamd_config *cfg)
stat_ctx->cfg = cfg;
stat_ctx->statfiles = g_ptr_array_new ();
stat_ctx->classifiers = g_ptr_array_new ();
+ stat_ctx->ev_base = ev_base;
REF_RETAIN (stat_ctx->cfg);
/* Create statfiles from the classifiers */
@@ -193,7 +194,6 @@ void
rspamd_stat_close (void)
{
guint i;
- struct rspamd_config *cfg = stat_ctx->cfg;
g_assert (stat_ctx != NULL);
diff --git a/src/libstat/stat_internal.h b/src/libstat/stat_internal.h
index 591c47381..7e5804b8b 100644
--- a/src/libstat/stat_internal.h
+++ b/src/libstat/stat_internal.h
@@ -83,6 +83,8 @@ struct rspamd_stat_ctx {
/* Global tokenizer */
struct rspamd_stat_tokenizer *tokenizer;
gpointer tkcf;
+
+ struct event_base *ev_base;
};
typedef enum rspamd_learn_cache_result {
diff --git a/src/worker.c b/src/worker.c
index 493707ebc..6e46c15a7 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -427,7 +427,7 @@ start_worker (struct rspamd_worker *worker)
/* XXX: stupid default */
ctx->keys_cache = rspamd_keypair_cache_new (256);
- rspamd_stat_init (worker->srv->cfg);
+ rspamd_stat_init (worker->srv->cfg, ctx->ev_base);
#ifdef WITH_HYPERSCAN
rspamd_control_worker_add_cmd_handler (worker, RSPAMD_CONTROL_HYPERSCAN_LOADED,
diff --git a/test/rspamd_test_suite.c b/test/rspamd_test_suite.c
index 4ba11ea0f..9ff50c626 100644
--- a/test/rspamd_test_suite.c
+++ b/test/rspamd_test_suite.c
@@ -28,9 +28,9 @@ main (int argc, char **argv)
g_test_init (&argc, &argv, NULL);
cfg->libs_ctx = rspamd_init_libs ();
- rspamd_stat_init (cfg);
base = event_init ();
+ rspamd_stat_init (cfg, base);
if (g_test_verbose ()) {
cfg->log_level = G_LOG_LEVEL_DEBUG;