commit 00d91c9: [Rework] Remove empty prefilters feature - we are not prepared...

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Sep 10 14:28:06 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-09-10 15:22:04 +0100
URL: https://github.com/rspamd/rspamd/commit/00d91c955e35021f1252eaffc23c491a2dd86123 (HEAD -> master)

[Rework] Remove empty prefilters feature - we are not prepared...

---
 src/libserver/rspamd_symcache.c | 61 ++---------------------------------------
 src/libserver/task.c            |  1 -
 src/libserver/task.h            | 32 ++++++++++-----------
 3 files changed, 17 insertions(+), 77 deletions(-)

diff --git a/src/libserver/rspamd_symcache.c b/src/libserver/rspamd_symcache.c
index 375dab54c..b1aa2afba 100644
--- a/src/libserver/rspamd_symcache.c
+++ b/src/libserver/rspamd_symcache.c
@@ -152,7 +152,6 @@ struct rspamd_symcache {
 	GPtrArray *items_by_id;
 	struct symcache_order *items_by_order;
 	GPtrArray *filters;
-	GPtrArray *prefilters_empty;
 	GPtrArray *prefilters;
 	GPtrArray *postfilters;
 	GPtrArray *composites;
@@ -745,7 +744,6 @@ rspamd_symcache_post_init (struct rspamd_symcache *cache)
 		}
 	}
 
-	g_ptr_array_sort_with_data (cache->prefilters_empty, prefilters_cmp, cache);
 	g_ptr_array_sort_with_data (cache->prefilters, prefilters_cmp, cache);
 	g_ptr_array_sort_with_data (cache->postfilters, postfilters_cmp, cache);
 	g_ptr_array_sort_with_data (cache->idempotent, postfilters_cmp, cache);
@@ -1103,16 +1101,8 @@ rspamd_symcache_add_symbol (struct rspamd_symcache *cache,
 
 		if (item->type & SYMBOL_TYPE_PREFILTER) {
 			type_str = "prefilter";
-
-			if (item->type & SYMBOL_TYPE_EMPTY) {
-				/* Executed before mime parsing stage */
-				g_ptr_array_add (cache->prefilters_empty, item);
-				item->container = cache->prefilters_empty;
-			}
-			else {
-				g_ptr_array_add (cache->prefilters, item);
-				item->container = cache->prefilters;
-			}
+			g_ptr_array_add (cache->prefilters, item);
+			item->container = cache->prefilters;
 		}
 		else if (item->type & SYMBOL_TYPE_IDEMPOTENT) {
 			type_str = "idempotent";
@@ -1311,7 +1301,6 @@ rspamd_symcache_destroy (struct rspamd_symcache *cache)
 		rspamd_mempool_delete (cache->static_pool);
 		g_ptr_array_free (cache->filters, TRUE);
 		g_ptr_array_free (cache->prefilters, TRUE);
-		g_ptr_array_free (cache->prefilters_empty, TRUE);
 		g_ptr_array_free (cache->postfilters, TRUE);
 		g_ptr_array_free (cache->idempotent, TRUE);
 		g_ptr_array_free (cache->composites, TRUE);
@@ -1339,7 +1328,6 @@ rspamd_symcache_new (struct rspamd_config *cfg)
 	cache->items_by_id = g_ptr_array_new ();
 	cache->filters = g_ptr_array_new ();
 	cache->prefilters = g_ptr_array_new ();
-	cache->prefilters_empty = g_ptr_array_new ();
 	cache->postfilters = g_ptr_array_new ();
 	cache->idempotent = g_ptr_array_new ();
 	cache->composites = g_ptr_array_new ();
@@ -2079,51 +2067,6 @@ rspamd_symcache_process_symbols (struct rspamd_task *task,
 	start_events_pending = rspamd_session_events_pending (task->s);
 
 	switch (stage) {
-	case RSPAMD_TASK_STAGE_PRE_FILTERS_EMPTY:
-		/* Check for prefilters */
-		saved_priority = G_MININT;
-		all_done = TRUE;
-
-		for (i = 0; i < (gint) cache->prefilters_empty->len; i++) {
-			item = g_ptr_array_index (cache->prefilters_empty, i);
-			dyn_item = rspamd_symcache_get_dynamic (checkpoint, item);
-
-			if (RSPAMD_TASK_IS_SKIPPED (task)) {
-				return TRUE;
-			}
-
-			if (!CHECK_START_BIT (checkpoint, dyn_item) &&
-				!CHECK_FINISH_BIT (checkpoint, dyn_item)) {
-
-				if (checkpoint->has_slow) {
-					/* Delay */
-					checkpoint->has_slow = FALSE;
-
-					return FALSE;
-				}
-				/* Check priorities */
-				if (saved_priority == G_MININT) {
-					saved_priority = item->priority;
-				}
-				else {
-					if (item->priority < saved_priority &&
-						rspamd_session_events_pending (task->s) > start_events_pending) {
-						/*
-						 * Delay further checks as we have higher
-						 * priority filters to be processed
-						 */
-						return FALSE;
-					}
-				}
-
-				rspamd_symcache_check_symbol (task, cache, item,
-						checkpoint);
-				all_done = FALSE;
-			}
-		}
-
-		break;
-
 	case RSPAMD_TASK_STAGE_PRE_FILTERS:
 		/* Check for prefilters */
 		saved_priority = G_MININT;
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 53da0dae6..6b93ac810 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -727,7 +727,6 @@ rspamd_task_process (struct rspamd_task *task, guint stages)
 		}
 		break;
 
-	case RSPAMD_TASK_STAGE_PRE_FILTERS_EMPTY:
 	case RSPAMD_TASK_STAGE_PRE_FILTERS:
 	case RSPAMD_TASK_STAGE_FILTERS:
 		all_done = rspamd_symcache_process_symbols (task, task->cfg->cache, st);
diff --git a/src/libserver/task.h b/src/libserver/task.h
index aa6d01a2e..0e23ea55d 100644
--- a/src/libserver/task.h
+++ b/src/libserver/task.h
@@ -42,27 +42,25 @@ enum rspamd_task_stage {
 	RSPAMD_TASK_STAGE_CONNECT = (1u << 0u),
 	RSPAMD_TASK_STAGE_ENVELOPE = (1u << 1u),
 	RSPAMD_TASK_STAGE_READ_MESSAGE = (1u << 2u),
-	RSPAMD_TASK_STAGE_PRE_FILTERS_EMPTY = (1u << 3u),
-	RSPAMD_TASK_STAGE_PROCESS_MESSAGE = (1u << 4u),
-	RSPAMD_TASK_STAGE_PRE_FILTERS = (1u << 5u),
-	RSPAMD_TASK_STAGE_FILTERS = (1u << 6u),
-	RSPAMD_TASK_STAGE_CLASSIFIERS_PRE = (1u << 7u),
-	RSPAMD_TASK_STAGE_CLASSIFIERS = (1u << 8u),
-	RSPAMD_TASK_STAGE_CLASSIFIERS_POST = (1u << 9u),
-	RSPAMD_TASK_STAGE_COMPOSITES = (1u << 10u),
-	RSPAMD_TASK_STAGE_POST_FILTERS = (1u << 11u),
-	RSPAMD_TASK_STAGE_LEARN_PRE = (1u << 12u),
-	RSPAMD_TASK_STAGE_LEARN = (1u << 13u),
-	RSPAMD_TASK_STAGE_LEARN_POST = (1u << 14u),
-	RSPAMD_TASK_STAGE_COMPOSITES_POST = (1u << 15u),
-	RSPAMD_TASK_STAGE_IDEMPOTENT = (1u << 16u),
-	RSPAMD_TASK_STAGE_DONE = (1u << 17u),
-	RSPAMD_TASK_STAGE_REPLIED = (1u << 18u)
+	RSPAMD_TASK_STAGE_PROCESS_MESSAGE = (1u << 3u),
+	RSPAMD_TASK_STAGE_PRE_FILTERS = (1u << 4u),
+	RSPAMD_TASK_STAGE_FILTERS = (1u << 5u),
+	RSPAMD_TASK_STAGE_CLASSIFIERS_PRE = (1u << 6u),
+	RSPAMD_TASK_STAGE_CLASSIFIERS = (1u << 7u),
+	RSPAMD_TASK_STAGE_CLASSIFIERS_POST = (1u << 8u),
+	RSPAMD_TASK_STAGE_COMPOSITES = (1u << 9u),
+	RSPAMD_TASK_STAGE_POST_FILTERS = (1u << 10u),
+	RSPAMD_TASK_STAGE_LEARN_PRE = (1u << 11u),
+	RSPAMD_TASK_STAGE_LEARN = (1u << 12u),
+	RSPAMD_TASK_STAGE_LEARN_POST = (1u << 13u),
+	RSPAMD_TASK_STAGE_COMPOSITES_POST = (1u << 14u),
+	RSPAMD_TASK_STAGE_IDEMPOTENT = (1u << 15u),
+	RSPAMD_TASK_STAGE_DONE = (1u << 16u),
+	RSPAMD_TASK_STAGE_REPLIED = (1u << 17u)
 };
 
 #define RSPAMD_TASK_PROCESS_ALL (RSPAMD_TASK_STAGE_CONNECT | \
         RSPAMD_TASK_STAGE_ENVELOPE | \
-        RSPAMD_TASK_STAGE_PRE_FILTERS_EMPTY | \
         RSPAMD_TASK_STAGE_READ_MESSAGE | \
         RSPAMD_TASK_STAGE_PRE_FILTERS | \
         RSPAMD_TASK_STAGE_PROCESS_MESSAGE | \


More information about the Commits mailing list