diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-09-05 16:20:46 +0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-05 16:20:46 +0600 |
commit | 737a2ce03b826f86851d021d628274ab8c8ea7fb (patch) | |
tree | 7918e548808c5981fab465726f545a5c6cc9fe49 /src/libserver/symcache/symcache_runtime.cxx | |
parent | dd47f82a317ad2ed9a9270c9779bf866ff5989fd (diff) | |
parent | 40a6ddd69be80e6a4ad8a29053bbfa18d24b3bd8 (diff) | |
download | rspamd-737a2ce03b826f86851d021d628274ab8c8ea7fb.tar.gz rspamd-737a2ce03b826f86851d021d628274ab8c8ea7fb.zip |
Merge branch 'master' into vstakhov-utf8-mime
Diffstat (limited to 'src/libserver/symcache/symcache_runtime.cxx')
-rw-r--r-- | src/libserver/symcache/symcache_runtime.cxx | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/libserver/symcache/symcache_runtime.cxx b/src/libserver/symcache/symcache_runtime.cxx index dc7066b32..ddfbdf1ae 100644 --- a/src/libserver/symcache/symcache_runtime.cxx +++ b/src/libserver/symcache/symcache_runtime.cxx @@ -333,8 +333,8 @@ auto symcache_runtime::process_pre_postfilters(struct rspamd_task *task, */ if (stage != RSPAMD_TASK_STAGE_IDEMPOTENT && !(item->flags & SYMBOL_TYPE_IGNORE_PASSTHROUGH)) { - if (check_metric_limit(task)) { - msg_debug_cache_task_lambda("task has already the result being set, ignore further checks"); + if (check_process_status(task) == check_status::passthrough) { + msg_debug_cache_task_lambda("task has already the passthrough result being set, ignore further checks"); return true; } @@ -407,13 +407,20 @@ auto symcache_runtime::process_filters(struct rspamd_task *task, symcache &cache break; } + auto check_result = check_process_status(task); + if (!(item->flags & (SYMBOL_TYPE_FINE | SYMBOL_TYPE_IGNORE_PASSTHROUGH))) { - if (has_passtrough || check_metric_limit(task)) { - msg_debug_cache_task_lambda("task has already the result being set, ignore further checks"); + if (has_passtrough || check_result == check_status::passthrough) { + msg_debug_cache_task_lambda("task has already the passthrough result being set, ignore further checks"); has_passtrough = true; /* Skip this item */ continue; } + else if (check_result == check_status::limit_reached) { + msg_debug_cache_task_lambda("task has already the limit reached result being set, ignore further checks"); + /* Skip this item */ + continue; + } } auto dyn_item = &dynamic_items[idx]; @@ -531,19 +538,8 @@ auto symcache_runtime::process_symbol(struct rspamd_task *task, symcache &cache, return true; } -auto symcache_runtime::check_metric_limit(struct rspamd_task *task) -> bool +auto symcache_runtime::check_process_status(struct rspamd_task *task) -> symcache_runtime::check_status { - if (task->flags & RSPAMD_TASK_FLAG_PASS_ALL) { - return false; - } - - /* Check score limit */ - if (!std::isnan(lim)) { - if (task->result->score > lim) { - return true; - } - } - if (task->result->passthrough_result != nullptr) { /* We also need to check passthrough results */ auto *pr = task->result->passthrough_result; @@ -563,11 +559,22 @@ auto symcache_runtime::check_metric_limit(struct rspamd_task *task) -> bool } /* Immediately stop on non least passthrough action */ - return true; + return check_status::passthrough; } } - return false; + if (task->flags & RSPAMD_TASK_FLAG_PASS_ALL) { + return check_status::allow; + } + + /* Check score limit */ + if (!std::isnan(lim)) { + if (task->result->score > lim) { + return check_status::limit_reached; + } + } + + return check_status::allow; } auto symcache_runtime::check_item_deps(struct rspamd_task *task, symcache &cache, cache_item *item, |