diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-10-08 16:27:15 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-10-08 16:35:42 +0100 |
commit | be2828419394df4339c793ce8526b5327da388d9 (patch) | |
tree | d2735974bc2b64710ed429828312b27392a17cc4 /src/libstat | |
parent | 561594bb943bfdc9c9b888c1eacc2a6d34ca882b (diff) | |
download | rspamd-be2828419394df4339c793ce8526b5327da388d9.tar.gz rspamd-be2828419394df4339c793ce8526b5327da388d9.zip |
[Minor] More fixes to backend-less classifiers
Diffstat (limited to 'src/libstat')
-rw-r--r-- | src/libstat/stat_config.c | 8 | ||||
-rw-r--r-- | src/libstat/stat_process.c | 10 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/libstat/stat_config.c b/src/libstat/stat_config.c index f153be737..8a953f47b 100644 --- a/src/libstat/stat_config.c +++ b/src/libstat/stat_config.c @@ -238,9 +238,13 @@ rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base) if (!(cl->cfg->flags & RSPAMD_FLAG_CLASSIFIER_NO_BACKEND)) { st->backend = bk; st->bkcf = bk->init (stat_ctx, cfg, st); + msg_debug_config ("added backend %s for symbol %s", + bk->name, stf->symbol); + } + else { + msg_debug_config ("added backend-less statfile for symbol %s", + stf->symbol); } - msg_debug_config ("added backend %s for symbol %s", - bk->name, stf->symbol); /* XXX: bad hack to pass statfiles configuration to cache */ if (cl->cache == NULL) { diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c index 7eeac00c1..ea0fcd601 100644 --- a/src/libstat/stat_process.c +++ b/src/libstat/stat_process.c @@ -275,6 +275,7 @@ rspamd_stat_preprocess (struct rspamd_stat_ctx *st_ctx, rspamd_stat_process_tokenize (st_ctx, task); task->stat_runtimes = g_ptr_array_sized_new (st_ctx->statfiles->len); + g_ptr_array_set_size (task->stat_runtimes, st_ctx->statfiles->len); rspamd_mempool_add_destructor (task->task_pool, rspamd_ptr_array_free_hard, task->stat_runtimes); @@ -282,6 +283,11 @@ rspamd_stat_preprocess (struct rspamd_stat_ctx *st_ctx, st = g_ptr_array_index (st_ctx->statfiles, i); g_assert (st != NULL); + if (st->classifier->cfg->flags & RSPAMD_FLAG_CLASSIFIER_NO_BACKEND) { + g_ptr_array_index (task->stat_runtimes, i) = NULL; + continue; + } + bk_run = st->backend->runtime (task, st->stcf, learn, st->bkcf); if (bk_run == NULL) { @@ -289,7 +295,7 @@ rspamd_stat_preprocess (struct rspamd_stat_ctx *st_ctx, st->backend->name, st->stcf->symbol); } - g_ptr_array_add (task->stat_runtimes, bk_run); + g_ptr_array_index (task->stat_runtimes, i) = bk_run; } } @@ -728,7 +734,7 @@ rspamd_stat_backends_learn (struct rspamd_stat_ctx *st_ctx, } end: - if (sel == NULL) { + if (!res && sel == NULL) { if (classifier) { g_set_error (err, rspamd_stat_quark (), 404, "cannot find classifier " "with name %s", classifier); |