From: Vsevolod Stakhov Date: Sun, 10 Jan 2016 23:27:51 +0000 (+0000) Subject: Fix caches initialization. X-Git-Tag: 1.1.0~79 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8bcc03ac88d6f99058bd1a6660f30cb535cf1515;p=thirdparty%2Frspamd.git Fix caches initialization. --- diff --git a/src/libstat/stat_config.c b/src/libstat/stat_config.c index d8b980aecb..0ae36af1b5 100644 --- a/src/libstat/stat_config.c +++ b/src/libstat/stat_config.c @@ -165,9 +165,10 @@ rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base) } } - cl->cache = rspamd_stat_get_cache (cache_name); - g_assert (cl->cache != NULL); - cl->cachecf = cl->cache->init (stat_ctx, cfg, cache_obj); + if (cache_name == NULL) { + /* We assume that learn cache is the same as backend */ + cache_name = clf->backend; + } curst = clf->statfiles; @@ -181,6 +182,12 @@ rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base) msg_debug_config ("added backend %s for symbol %s", bk->name, stf->symbol); + st->cache = rspamd_stat_get_cache (cache_name); + g_assert (st->cache != NULL); + st->cachecf = st->cache->init (stat_ctx, cfg, st, cache_obj); + msg_debug_config ("added cache %s for symbol %s", + st->cache->name, stf->symbol); + if (st->bkcf == NULL) { msg_err_config ("cannot init backend %s for statfile %s", clf->backend, stf->symbol); @@ -363,7 +370,6 @@ rspamd_stat_ctx_register_async (rspamd_stat_async_handler handler, { struct rspamd_stat_async_elt *elt; struct rspamd_stat_ctx *st_ctx; - gdouble jittered_time; st_ctx = rspamd_stat_get_ctx (); g_assert (st_ctx != NULL); diff --git a/src/libstat/stat_internal.h b/src/libstat/stat_internal.h index 7a3951a0e5..52e3d728b4 100644 --- a/src/libstat/stat_internal.h +++ b/src/libstat/stat_internal.h @@ -41,8 +41,6 @@ struct rspamd_statfile_runtime { /* Common classifier structure */ struct rspamd_classifier { struct rspamd_stat_ctx *ctx; - struct rspamd_stat_cache *cache; - gpointer cachecf; GArray *statfiles_ids; gulong spam_learns; gulong ham_learns; @@ -55,6 +53,8 @@ struct rspamd_statfile { struct rspamd_statfile_config *stcf; struct rspamd_classifier *classifier; struct rspamd_stat_backend *backend; + struct rspamd_stat_cache *cache; + gpointer cachecf; gpointer bkcf; };