From: Vsevolod Stakhov Date: Thu, 15 Mar 2018 14:00:10 +0000 (+0000) Subject: [Fix] Improve cached action interaction X-Git-Tag: 1.7.1~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a580591aabfda1fc1474c8baba45b8b9a679195;p=thirdparty%2Frspamd.git [Fix] Improve cached action interaction --- diff --git a/src/libmime/filter.c b/src/libmime/filter.c index 59765ea59a..08a589189e 100644 --- a/src/libmime/filter.c +++ b/src/libmime/filter.c @@ -353,7 +353,17 @@ rspamd_check_action_metric (struct rspamd_task *task, struct rspamd_metric_resul struct rspamd_action *action, *selected_action = NULL; double max_score = -(G_MAXDOUBLE), sc; int i; + gboolean set_action = FALSE; + if (task->processed_stages | (RSPAMD_TASK_STAGE_DONE|RSPAMD_TASK_STAGE_IDEMPOTENT)) { + if (mres->action != METRIC_ACTION_MAX) { + return mres->action; + } + + set_action = TRUE; + } + + /* We are not certain about the results during processing */ if (task->pre_result.action == METRIC_ACTION_MAX) { for (i = METRIC_ACTION_REJECT; i < METRIC_ACTION_MAX; i++) { action = &task->cfg->actions[i]; @@ -399,6 +409,10 @@ rspamd_check_action_metric (struct rspamd_task *task, struct rspamd_metric_resul } if (selected_action) { + if (set_action) { + mres->action = selected_action->action; + } + return selected_action->action; } diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index d9bcecb637..103ad85882 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -1376,12 +1376,7 @@ end: if (metric_res != NULL) { - if (metric_res->action != METRIC_ACTION_MAX) { - action = metric_res->action; - } - else { - action = rspamd_check_action_metric (task, metric_res); - } + action = rspamd_check_action_metric (task, metric_res); if (action == METRIC_ACTION_SOFT_REJECT && (task->flags & RSPAMD_TASK_FLAG_GREYLISTED)) { diff --git a/src/libserver/roll_history.c b/src/libserver/roll_history.c index 01aa9f88a1..4d1d34bd9c 100644 --- a/src/libserver/roll_history.c +++ b/src/libserver/roll_history.c @@ -151,7 +151,7 @@ rspamd_roll_history_update (struct roll_history *history, } else { row->score = metric_res->score; - row->action = metric_res->action; + row->action = rspamd_check_action_metric (task, metric_res); row->required_score = rspamd_task_get_required_score (task, metric_res); cbdata.pos = row->symbols; cbdata.remain = sizeof (row->symbols); diff --git a/src/libserver/task.c b/src/libserver/task.c index 55a00649de..ce21523e7d 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -1036,6 +1036,7 @@ rspamd_task_log_metric_res (struct rspamd_task *task, guint i, j; mres = task->result; + rspamd_check_action_metric (task, mres); if (mres != NULL) { switch (lf->type) { diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c index 2284907a1e..aed9d383d3 100644 --- a/src/libstat/stat_process.c +++ b/src/libstat/stat_process.c @@ -1121,9 +1121,6 @@ rspamd_stat_check_autolearn (struct rspamd_task *task) mres = task->result; if (mres) { - - mres->action = rspamd_check_action_metric (task, mres); - if (mres->score > rspamd_task_get_required_score (task, mres)) { task->flags |= RSPAMD_TASK_FLAG_LEARN_SPAM;