]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Improve cached action interaction
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 15 Mar 2018 14:00:10 +0000 (14:00 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 15 Mar 2018 14:00:10 +0000 (14:00 +0000)
src/libmime/filter.c
src/libserver/protocol.c
src/libserver/roll_history.c
src/libserver/task.c
src/libstat/stat_process.c

index 59765ea59a9a2759ae07e5829785bdce84059a93..08a589189e823d866f7e9f08b9ec2002d58bffaf 100644 (file)
@@ -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;
        }
 
index d9bcecb6374d955786eca3deaec465539f2d6351..103ad85882c359dd7501506c6f31aa20a4b265a3 100644 (file)
@@ -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)) {
index 01aa9f88a1185c7ff9107580a585cdc5e51a3048..4d1d34bd9cdc2d2bb8bb3fbb96d4e2a477f2abc5 100644 (file)
@@ -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);
index 55a00649deabab726bc8b3f118ccfbbe12d8e547..ce21523e7d70828f8f14f2c9b1007fa37a5c7592 100644 (file)
@@ -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) {
index 2284907a1e9517b598ff410b4c5ac4ccf33968b4..aed9d383d364a8eff3d58abfc8f305191cc176ce 100644 (file)
@@ -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;