GHashTable *items_by_symbol;
GPtrArray *items_by_id;
struct symcache_order *items_by_order;
- GPtrArray *filters;
+ GPtrArray *connfilters;
GPtrArray *prefilters;
+ GPtrArray *filters;
GPtrArray *postfilters;
GPtrArray *composites;
GPtrArray *idempotent;
}
}
+ g_ptr_array_sort_with_data (cache->connfilters, 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);
g_ptr_array_add (cache->postfilters, item);
item->container = cache->postfilters;
}
+ else if (item->type & SYMBOL_TYPE_CONNFILTER) {
+ type_str = "connfilter";
+ g_ptr_array_add (cache->connfilters, item);
+ item->container = cache->connfilters;
+ }
else {
item->is_filter = TRUE;
g_ptr_array_add (cache->filters, item);
g_hash_table_destroy (cache->items_by_symbol);
g_ptr_array_free (cache->items_by_id, TRUE);
rspamd_mempool_delete (cache->static_pool);
- g_ptr_array_free (cache->filters, TRUE);
+ g_ptr_array_free (cache->connfilters, TRUE);
g_ptr_array_free (cache->prefilters, TRUE);
+ g_ptr_array_free (cache->filters, TRUE);
g_ptr_array_free (cache->postfilters, TRUE);
g_ptr_array_free (cache->idempotent, TRUE);
g_ptr_array_free (cache->composites, TRUE);
cache->items_by_symbol = g_hash_table_new (rspamd_str_hash,
rspamd_str_equal);
cache->items_by_id = g_ptr_array_new ();
- cache->filters = g_ptr_array_new ();
+ cache->connfilters = g_ptr_array_new ();
cache->prefilters = g_ptr_array_new ();
+ cache->filters = g_ptr_array_new ();
cache->postfilters = g_ptr_array_new ();
cache->idempotent = g_ptr_array_new ();
cache->composites = g_ptr_array_new ();
start_events_pending = rspamd_session_events_pending (task->s);
switch (stage) {
+ case RSPAMD_TASK_STAGE_CONNFILTERS:
+ /* Check for connection filters */
+ saved_priority = G_MININT;
+ all_done = TRUE;
+
+ for (i = 0; i < (gint) cache->connfilters->len; i++) {
+ item = g_ptr_array_index (cache->connfilters, 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;
SYMBOL_TYPE_CLASSIFIER = (1u << 6u),
SYMBOL_TYPE_FINE = (1u << 7u),
SYMBOL_TYPE_EMPTY = (1u << 8u), /* Allow execution on empty tasks */
- SYMBOL_TYPE_PREFILTER = (1u << 9u),
- SYMBOL_TYPE_POSTFILTER = (1u << 10u),
- SYMBOL_TYPE_NOSTAT = (1u << 11u), /* Skip as statistical symbol */
- SYMBOL_TYPE_IDEMPOTENT = (1u << 12u), /* Symbol cannot change metric */
+ SYMBOL_TYPE_CONNFILTER = (1u << 9u), /* Connection stage filter */
+ SYMBOL_TYPE_PREFILTER = (1u << 10u),
+ SYMBOL_TYPE_POSTFILTER = (1u << 11u),
+ SYMBOL_TYPE_NOSTAT = (1u << 12u), /* Skip as statistical symbol */
+ SYMBOL_TYPE_IDEMPOTENT = (1u << 13u), /* Symbol cannot change metric */
SYMBOL_TYPE_TRIVIAL = (1u << 14u), /* Symbol is trivial */
SYMBOL_TYPE_MIME_ONLY = (1u << 15u), /* Symbol is mime only */
SYMBOL_TYPE_EXPLICIT_DISABLE = (1u << 16u), /* Symbol should be disabled explicitly only */
enum rspamd_task_stage {
RSPAMD_TASK_STAGE_CONNECT = (1u << 0u),
- RSPAMD_TASK_STAGE_ENVELOPE = (1u << 1u),
+ RSPAMD_TASK_STAGE_CONNFILTERS = (1u << 1u),
RSPAMD_TASK_STAGE_READ_MESSAGE = (1u << 2u),
RSPAMD_TASK_STAGE_PROCESS_MESSAGE = (1u << 3u),
RSPAMD_TASK_STAGE_PRE_FILTERS = (1u << 4u),
};
#define RSPAMD_TASK_PROCESS_ALL (RSPAMD_TASK_STAGE_CONNECT | \
- RSPAMD_TASK_STAGE_ENVELOPE | \
+ RSPAMD_TASK_STAGE_CONNFILTERS | \
RSPAMD_TASK_STAGE_READ_MESSAGE | \
RSPAMD_TASK_STAGE_PRE_FILTERS | \
RSPAMD_TASK_STAGE_PROCESS_MESSAGE | \
RSPAMD_TASK_STAGE_IDEMPOTENT | \
RSPAMD_TASK_STAGE_DONE)
#define RSPAMD_TASK_PROCESS_LEARN (RSPAMD_TASK_STAGE_CONNECT | \
- RSPAMD_TASK_STAGE_ENVELOPE | \
RSPAMD_TASK_STAGE_READ_MESSAGE | \
RSPAMD_TASK_STAGE_PROCESS_MESSAGE | \
RSPAMD_TASK_STAGE_CLASSIFIERS_PRE | \