]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Symcache: Stop on non least passthrough results
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 14 May 2022 12:41:45 +0000 (13:41 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 14 May 2022 12:41:45 +0000 (13:41 +0100)
src/libmime/scan_result.c
src/libmime/scan_result.h
src/libserver/symcache/symcache_runtime.cxx

index d5c03b2c44bbd2e3612b987c33be1167138fd7b7..e628eb1f39f6faccdea637c61ddef6f25d27a557 100644 (file)
@@ -806,7 +806,7 @@ rspamd_task_add_result_option (struct rspamd_task *task,
        return ret;
 }
 
-static struct rspamd_action_config *
+struct rspamd_action_config *
 rspamd_find_action_config_for_action (struct rspamd_scan_result *scan_result,
                                                                          struct rspamd_action *act)
 {
index 2f982fd1b767d0b12a6a91088976545441c49296..ec0aa9f4d5a2538afbfd8c52ff3108ac076757f7 100644 (file)
@@ -224,6 +224,9 @@ struct rspamd_action *rspamd_check_action_metric (struct rspamd_task *task,
                                                                                                  struct rspamd_passthrough_result **ppr,
                                                                                                  struct rspamd_scan_result *scan_result);
 
+struct rspamd_action_config *rspamd_find_action_config_for_action (struct rspamd_scan_result *scan_result,
+                                                                                                                                  struct rspamd_action *act);
+
 #ifdef  __cplusplus
 }
 #endif
index 1bcebbdc76534579d077d1f644cd5741830f0753..4bfa99529c9c0b074ac811bb30203a6ab228607b 100644 (file)
@@ -20,6 +20,7 @@
 #include "libutil/cxx/util.hxx"
 #include "libserver/task.h"
 #include "libmime/scan_result.h"
+#include "utlist.h"
 #include "libserver/worker_util.h"
 #include <limits>
 #include <cmath>
@@ -525,6 +526,28 @@ symcache_runtime::check_metric_limit(struct rspamd_task *task) -> bool
                }
        }
 
+       if (task->result->passthrough_result != nullptr) {
+               /* We also need to check passthrough results */
+               auto *pr = task->result->passthrough_result;
+               DL_FOREACH (task->result->passthrough_result, pr) {
+                       struct rspamd_action_config *act_config =
+                                       rspamd_find_action_config_for_action(task->result, pr->action);
+
+                       /* Skip least results */
+                       if (pr->flags & RSPAMD_PASSTHROUGH_LEAST) {
+                               continue;
+                       }
+
+                       /* Skip disabled actions */
+                       if (act_config && (act_config->flags & RSPAMD_ACTION_RESULT_DISABLED)) {
+                               continue;
+                       }
+
+                       /* Immediately stop on non least passthrough action */
+                       return true;
+               }
+       }
+
        return false;
 }