diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-12 14:54:43 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-12 15:57:33 +0000 |
commit | aa26e139bad1744a36d3878804e22116f90afafb (patch) | |
tree | f57503c2c5c6b5e2fd5f0a44c945cddec07a6b13 /src/libstat/stat_process.c | |
parent | f6dcd96b784a68846666cfa4de060446c9c11983 (diff) | |
download | rspamd-aa26e139bad1744a36d3878804e22116f90afafb.tar.gz rspamd-aa26e139bad1744a36d3878804e22116f90afafb.zip |
[Fix] Propagate learn/stat errors more precisely
Diffstat (limited to 'src/libstat/stat_process.c')
-rw-r--r-- | src/libstat/stat_process.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c index 886108d5d..e09673783 100644 --- a/src/libstat/stat_process.c +++ b/src/libstat/stat_process.c @@ -456,7 +456,7 @@ rspamd_stat_backends_process (struct rspamd_stat_ctx *st_ctx, } } -static void +static gboolean rspamd_stat_backends_post_process (struct rspamd_stat_ctx *st_ctx, struct rspamd_task *task) { @@ -478,9 +478,13 @@ rspamd_stat_backends_post_process (struct rspamd_stat_ctx *st_ctx, bk_run = g_ptr_array_index (task->stat_runtimes, i); if (bk_run != NULL) { - st->backend->finalize_process (task, bk_run, st_ctx); + if (!st->backend->finalize_process (task, bk_run, st_ctx)) { + return FALSE; + } } } + + return TRUE; } static void @@ -611,8 +615,10 @@ rspamd_stat_classify (struct rspamd_task *task, lua_State *L, guint stage, } else if (stage == RSPAMD_TASK_STAGE_CLASSIFIERS_POST) { /* Process classifiers */ - rspamd_stat_backends_post_process (st_ctx, task); - rspamd_stat_classifiers_process (st_ctx, task); + if (rspamd_stat_backends_post_process (st_ctx, task)) { + rspamd_stat_classifiers_process (st_ctx, task); + } + /* Do not process classifiers on backend failures */ } task->processed_stages |= stage; @@ -938,8 +944,9 @@ end: static gboolean rspamd_stat_backends_post_learn (struct rspamd_stat_ctx *st_ctx, struct rspamd_task *task, - const gchar *classifier, - gboolean spam) + const gchar *classifier, + gboolean spam, + GError **err) { struct rspamd_classifier *cl; struct rspamd_statfile *st; @@ -957,11 +964,6 @@ rspamd_stat_backends_post_learn (struct rspamd_stat_ctx *st_ctx, continue; } - if (cl->cache) { - cache_run = cl->cache->runtime (task, cl->cachecf, TRUE); - cl->cache->learn (task, spam, cache_run); - } - if (cl->cfg->flags & RSPAMD_FLAG_CLASSIFIER_NO_BACKEND) { res = TRUE; continue; @@ -979,7 +981,14 @@ rspamd_stat_backends_post_learn (struct rspamd_stat_ctx *st_ctx, continue; } - st->backend->finalize_learn (task, bk_run, st_ctx); + if (!st->backend->finalize_learn (task, bk_run, st_ctx, err)) { + return RSPAMD_STAT_PROCESS_ERROR; + } + } + + if (cl->cache) { + cache_run = cl->cache->runtime (task, cl->cachecf, TRUE); + cl->cache->learn (task, spam, cache_run); } } @@ -1029,7 +1038,7 @@ rspamd_stat_learn (struct rspamd_task *task, } } else if (stage == RSPAMD_TASK_STAGE_LEARN_POST) { - if (!rspamd_stat_backends_post_learn (st_ctx, task, classifier, spam)) { + if (!rspamd_stat_backends_post_learn (st_ctx, task, classifier, spam, err)) { return RSPAMD_STAT_PROCESS_ERROR; } } |