unsigned int cand_len;
enum rspamd_language_category cat;
struct rspamd_lang_detector_res *cand;
- enum rspamd_language_detected_type r;
+ enum rspamd_language_detected_type r = rs_detect_none;
struct rspamd_frequency_sort_cbdata cbd;
/* Check if we have sorted candidates based on frequency */
gboolean frequency_heuristic_applied = FALSE, ret = FALSE, internal_heuristic_applied = FALSE;
*/
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;
}
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];
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;
}
/* 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,
enabled = 1,
disabled = 2,
} slow_status;
+ enum class check_status {
+ allow,
+ limit_reached,
+ passthrough,
+ };
bool profile;
double profile_start;
/* Specific stages of the processing */
auto process_pre_postfilters(struct rspamd_task *task, symcache &cache, int start_events, unsigned int stage) -> bool;
auto process_filters(struct rspamd_task *task, symcache &cache, int start_events) -> bool;
- auto check_metric_limit(struct rspamd_task *task) -> bool;
+ auto check_process_status(struct rspamd_task *task) -> check_status;
auto check_item_deps(struct rspamd_task *task, symcache &cache, cache_item *item,
cache_dynamic_item *dyn_item, bool check_only) -> bool;