commit 5b0be50: [Minor] Symcache: Stop on non least passthrough results
Vsevolod Stakhov
vsevolod at rspamd.com
Sat May 14 12:49:10 UTC 2022
Author: Vsevolod Stakhov
Date: 2022-05-14 13:41:45 +0100
URL: https://github.com/rspamd/rspamd/commit/5b0be50b9446d29748431af9385fba97926e6bc6
[Minor] Symcache: Stop on non least passthrough results
---
src/libmime/scan_result.c | 2 +-
src/libmime/scan_result.h | 3 +++
src/libserver/symcache/symcache_runtime.cxx | 23 +++++++++++++++++++++++
3 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/src/libmime/scan_result.c b/src/libmime/scan_result.c
index d5c03b2c4..e628eb1f3 100644
--- a/src/libmime/scan_result.c
+++ b/src/libmime/scan_result.c
@@ -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)
{
diff --git a/src/libmime/scan_result.h b/src/libmime/scan_result.h
index 2f982fd1b..ec0aa9f4d 100644
--- a/src/libmime/scan_result.h
+++ b/src/libmime/scan_result.h
@@ -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
diff --git a/src/libserver/symcache/symcache_runtime.cxx b/src/libserver/symcache/symcache_runtime.cxx
index 1bcebbdc7..4bfa99529 100644
--- a/src/libserver/symcache/symcache_runtime.cxx
+++ b/src/libserver/symcache/symcache_runtime.cxx
@@ -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;
}
More information about the Commits
mailing list