Browse Source

Fix caches initialization.

tags/1.1.0
Vsevolod Stakhov 8 years ago
parent
commit
8bcc03ac88
2 changed files with 12 additions and 6 deletions
  1. 10
    4
      src/libstat/stat_config.c
  2. 2
    2
      src/libstat/stat_internal.h

+ 10
- 4
src/libstat/stat_config.c View File

@@ -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);

+ 2
- 2
src/libstat/stat_internal.h View File

@@ -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;
};


Loading…
Cancel
Save