From 29b7115762ad84865b6b657c8f5e88aba16e8eb4 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 5 Jan 2016 19:04:24 +0000 Subject: [PATCH] Fix init/deinit of statistics --- src/libstat/classifiers/classifiers.h | 1 + src/libstat/stat_config.c | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libstat/classifiers/classifiers.h b/src/libstat/classifiers/classifiers.h index 52b9a89f7..86395c96d 100644 --- a/src/libstat/classifiers/classifiers.h +++ b/src/libstat/classifiers/classifiers.h @@ -4,6 +4,7 @@ #include "config.h" #include "mem_pool.h" +#define RSPAMD_DEFAULT_CLASSIFIER "bayes" /* Consider this value as 0 */ #define ALPHA 0.0001 diff --git a/src/libstat/stat_config.c b/src/libstat/stat_config.c index 32d09f4a9..1f16a98de 100644 --- a/src/libstat/stat_config.c +++ b/src/libstat/stat_config.c @@ -135,7 +135,7 @@ rspamd_stat_init (struct rspamd_config *cfg) cl->cfg = clf; cl->ctx = stat_ctx; cl->statfiles_ids = g_array_new (FALSE, FALSE, sizeof (gint)); - cl->subrs = rspamd_stat_get_classifier (clf->name); + cl->subrs = rspamd_stat_get_classifier (clf->classifier); g_assert (cl->subrs != NULL); cl->subrs->init_func (cfg->cfg_pool, cl); @@ -197,12 +197,7 @@ rspamd_stat_close (void) g_assert (stat_ctx != NULL); - for (i = 0; i < stat_ctx->backends_count; i ++) { - if (stat_ctx->backends_subrs[i].close != NULL) { - stat_ctx->backends_subrs[i].close (stat_ctx->backends_subrs[i].ctx); - msg_debug_config ("closed backend %s", stat_ctx->backends_subrs[i].name); - } - } + /* TODO: add cleanup routine */ REF_RELEASE (stat_ctx->cfg); } @@ -218,6 +213,10 @@ rspamd_stat_get_classifier (const gchar *name) { guint i; + if (name == NULL || name[0] == '\0') { + name = RSPAMD_DEFAULT_CLASSIFIER; + } + for (i = 0; i < stat_ctx->classifiers_count; i ++) { if (strcmp (name, stat_ctx->classifiers_subrs[i].name) == 0) { return &stat_ctx->classifiers_subrs[i]; -- 2.39.5