]> source.dussan.org Git - rspamd.git/commitdiff
Store event base in statistics library
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 6 Jan 2016 15:25:07 +0000 (15:25 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 6 Jan 2016 15:25:07 +0000 (15:25 +0000)
src/controller.c
src/libstat/stat_api.h
src/libstat/stat_config.c
src/libstat/stat_internal.h
src/worker.c
test/rspamd_test_suite.c

index 0a359a9a6d461e9fabf8f0b040edd4e27f3a582e..e5b06c2db31485fceeaf817c4e4daca5ade1bda1 100644 (file)
@@ -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 ();
index 1cdd2f0292485f98d4bea8845b493d11cc426798..a63ee373480cb03f2a36797433833c4e568f86cc 100644 (file)
@@ -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
index 1f16a98de37a9c321018f4206fc4d9d84efb0cc3..bca4cd954c771fcf072fd0d51d8132a074489cae 100644 (file)
@@ -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);
 
index 591c473814916b391c9842dc59b0d5ffe9ca6a39..7e5804b8bfd0bf14f570921326f84d8780421ed9 100644 (file)
@@ -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 {
index 493707ebc8c4e8600c1aa096082656a379a5931c..6e46c15a755df07ceb9e2ac8dc2009c997b672bd 100644 (file)
@@ -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,
index 4ba11ea0fa4cf28b9db6c1332c9dbaddf08a8fcd..9ff50c6263a2c65ca8411a106389352e6a4b2236 100644 (file)
@@ -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;