]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Allow to skip composites second pass
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 8 Dec 2020 15:09:08 +0000 (15:09 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 8 Dec 2020 15:09:08 +0000 (15:09 +0000)
src/libmime/scan_result.c
src/libmime/scan_result.h
src/libserver/task.c

index 7b92510ca22a70553430f1bef4536af420a67352..1a2d96d832076bf07b7ea4fbecc4916f92397d10 100644 (file)
@@ -158,6 +158,8 @@ rspamd_add_passthrough_result (struct rspamd_task *task, struct rspamd_action *a
                                flags & RSPAMD_PASSTHROUGH_LEAST ? "*least " : "",
                                message, module, priority);
        }
+
+       scan_result->nresults ++;
 }
 
 static inline gdouble
@@ -474,6 +476,7 @@ insert_metric_result (struct rspamd_task *task,
                        symbol,
                        s->score,
                        final_score);
+       metric_res->nresults ++;
 
        return s;
 }
@@ -730,6 +733,8 @@ rspamd_task_add_result_option (struct rspamd_task *task,
                ret = TRUE;
        }
 
+       task->result->nresults ++;
+
        return ret;
 }
 
index d82699a91a526bd575b70951d64b2140aab2f234..c2b1088dabe5fa30e54c20c6b8bb52c33f7d47f6 100644 (file)
@@ -89,6 +89,8 @@ struct rspamd_scan_result {
        guint nactions;
        guint npositive;
        guint nnegative;
+       guint nresults; /**< all results: positive, negative, passthrough etc */
+       guint nresults_postfilters; /**< how many results are there before postfilters stage */
        struct rspamd_scan_result *prev, *next;           /**< double linked list of results */
 };
 
index 80216537fb3dd7c535f7bf1d3ea7029fc2a4e717..0969338038d9d3ce3218ef3b516365945b7e6237 100644 (file)
@@ -756,6 +756,7 @@ rspamd_task_process (struct rspamd_task *task, guint stages)
 
        case RSPAMD_TASK_STAGE_COMPOSITES:
                rspamd_composites_process_task (task);
+               task->result->nresults_postfilters = task->result->nresults;
                break;
 
        case RSPAMD_TASK_STAGE_POST_FILTERS:
@@ -813,8 +814,13 @@ rspamd_task_process (struct rspamd_task *task, guint stages)
                }
                break;
        case RSPAMD_TASK_STAGE_COMPOSITES_POST:
-               /* Second run of composites processing before idempotent filters */
-               rspamd_composites_process_task (task);
+               /* Second run of composites processing before idempotent filters (if needed) */
+               if (task->result->nresults_postfilters != task->result->nresults) {
+                       rspamd_composites_process_task (task);
+               }
+               else {
+                       msg_debug_task ("skip second run of composites as the result has not been changed");
+               }
                break;
 
        case RSPAMD_TASK_STAGE_IDEMPOTENT: