commit cbf7157: [Minor] Allow to skip composites second pass

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Dec 8 15:14:06 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-12-08 15:09:08 +0000
URL: https://github.com/rspamd/rspamd/commit/cbf7157e47e1e94d0653bc291767c2991e96158f (HEAD -> master)

[Minor] Allow to skip composites second pass

---
 src/libmime/scan_result.c |  5 +++++
 src/libmime/scan_result.h |  2 ++
 src/libserver/task.c      | 10 ++++++++--
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/libmime/scan_result.c b/src/libmime/scan_result.c
index 7b92510ca..1a2d96d83 100644
--- a/src/libmime/scan_result.c
+++ b/src/libmime/scan_result.c
@@ -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;
 }
 
diff --git a/src/libmime/scan_result.h b/src/libmime/scan_result.h
index d82699a91..c2b1088da 100644
--- a/src/libmime/scan_result.h
+++ b/src/libmime/scan_result.h
@@ -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 */
 };
 
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 80216537f..096933803 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -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:


More information about the Commits mailing list