]> source.dussan.org Git - rspamd.git/commitdiff
[Rework] Remove empty prefilters feature - we are not prepared...
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 10 Sep 2020 14:22:04 +0000 (15:22 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 10 Sep 2020 14:22:04 +0000 (15:22 +0100)
src/libserver/rspamd_symcache.c
src/libserver/task.c
src/libserver/task.h

index 375dab54cdd363b182ff4b25debb656a9f453ab9..b1aa2afbaceecb08334629023f7e30213d37bd0a 100644 (file)
@@ -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;
index 53da0dae626702d3cc877cb6cbff05f9b313e7cb..6b93ac8101969568ce31db2101eab96370f158fc 100644 (file)
@@ -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);
index aa6d01a2e8b9147fd236f52b8d0954e2e4f684a7..0e23ea55dea615e47f591d8909df7f99019e2421 100644 (file)
@@ -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 | \