commit ec85b5f: [Minor] Remove priorities from idempotent filters

Vsevolod Stakhov vsevolod at rspamd.com
Sat Sep 10 14:00:03 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-09-10 14:27:15 +0100
URL: https://github.com/rspamd/rspamd/commit/ec85b5f367893a9cdc99b1543bbcde849d92e7ef

[Minor] Remove priorities from idempotent filters

---
 src/libserver/symcache/symcache_impl.cxx | 15 ++++++++++-----
 src/libserver/worker_util.c              |  2 +-
 src/plugins/lua/aws_s3.lua               |  2 +-
 src/plugins/lua/clickhouse.lua           |  1 -
 src/plugins/lua/elastic.lua              |  1 -
 src/plugins/lua/greylist.lua             |  2 ++
 src/plugins/lua/history_redis.lua        |  1 -
 src/plugins/lua/metadata_exporter.lua    |  1 -
 src/plugins/lua/milter_headers.lua       |  1 -
 src/plugins/lua/neural.lua               |  1 -
 src/plugins/lua/replies.lua              |  1 -
 test/functional/lua/neural.lua           |  1 -
 12 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/src/libserver/symcache/symcache_impl.cxx b/src/libserver/symcache/symcache_impl.cxx
index e7e0a56b0..451222f2f 100644
--- a/src/libserver/symcache/symcache_impl.cxx
+++ b/src/libserver/symcache/symcache_impl.cxx
@@ -735,11 +735,6 @@ auto symcache::add_symbol_with_callback(std::string_view name,
 		return -1;
 	}
 
-	if ((real_type_pair.second & SYMBOL_TYPE_FINE) && priority == 0) {
-		/* Adjust priority for negative weighted symbols */
-		priority = 1;
-	}
-
 	std::string static_string_name;
 
 	if (name.empty()) {
@@ -751,6 +746,16 @@ auto symcache::add_symbol_with_callback(std::string_view name,
 		static_string_name = name;
 	}
 
+	if (real_type_pair.first == symcache_item_type::IDEMPOTENT && priority != 0) {
+		msg_warn_cache("priority has been set for idempotent symbol %s: %d",
+				static_string_name.c_str(), priority);
+	}
+
+	if ((real_type_pair.second & SYMBOL_TYPE_FINE) && priority == 0) {
+		/* Adjust priority for negative weighted symbols */
+		priority = 1;
+	}
+
 	if (items_by_symbol.contains(static_string_name)) {
 		msg_err_cache("duplicate symbol name: %s", static_string_name.data());
 		return -1;
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index 5e296b1d9..f9d089a9b 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -2255,7 +2255,7 @@ rspamd_worker_check_and_adjust_timeout (struct rspamd_config *cfg, gdouble timeo
 			}
 		}
 		msg_info_config("list of top %d symbols by execution time: %v",
-				MIN(tres->nitems, max_displayed_items),
+				(int)MIN(tres->nitems, max_displayed_items),
 				buf);
 
 		g_string_free(buf, TRUE);
diff --git a/src/plugins/lua/aws_s3.lua b/src/plugins/lua/aws_s3.lua
index 3bce7913c..a1b30e4ed 100644
--- a/src/plugins/lua/aws_s3.lua
+++ b/src/plugins/lua/aws_s3.lua
@@ -261,6 +261,6 @@ rspamd_config:register_symbol({
   name = 'EXPORT_AWS_S3',
   type = settings.fail_action and 'postfilter' or 'idempotent',
   callback = s3_aws_callback,
-  priority = 10,
+  priority = settings.fail_action and 10 or nil,
   flags = 'empty,explicit_disable,ignore_passthrough,nostat',
 })
\ No newline at end of file
diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua
index b8f418abd..ce1749874 100644
--- a/src/plugins/lua/clickhouse.lua
+++ b/src/plugins/lua/clickhouse.lua
@@ -1467,7 +1467,6 @@ if opts then
       name = 'CLICKHOUSE_COLLECT',
       type = 'idempotent',
       callback = clickhouse_collect,
-      priority = 10,
       flags = 'empty,explicit_disable,ignore_passthrough',
       augmentations = {string.format("timeout=%f", settings.timeout)},
     })
diff --git a/src/plugins/lua/elastic.lua b/src/plugins/lua/elastic.lua
index 5578d48ec..8d20720bc 100644
--- a/src/plugins/lua/elastic.lua
+++ b/src/plugins/lua/elastic.lua
@@ -517,7 +517,6 @@ if redis_params and opts then
       name = 'ELASTIC_COLLECT',
       type = 'idempotent',
       callback = elastic_collect,
-      priority = 10,
       flags = 'empty,explicit_disable,ignore_passthrough',
       augmentations = {string.format("timeout=%f", settings.timeout)},
     })
diff --git a/src/plugins/lua/greylist.lua b/src/plugins/lua/greylist.lua
index ae2cd02f9..04e003a1b 100644
--- a/src/plugins/lua/greylist.lua
+++ b/src/plugins/lua/greylist.lua
@@ -515,12 +515,14 @@ if opts then
       type = 'postfilter',
       callback = greylist_set,
       priority = 6,
+      augmentations = {string.format("timeout=%f", redis_params.timeout or 0.0)},
     })
     local id = rspamd_config:register_symbol({
       name = 'GREYLIST_CHECK',
       type = 'prefilter',
       callback = greylist_check,
       priority = 6,
+      augmentations = {string.format("timeout=%f", redis_params.timeout or 0.0)}
     })
     rspamd_config:register_symbol({
       name = settings.symbol,
diff --git a/src/plugins/lua/history_redis.lua b/src/plugins/lua/history_redis.lua
index 35bfb9242..01645a410 100644
--- a/src/plugins/lua/history_redis.lua
+++ b/src/plugins/lua/history_redis.lua
@@ -290,7 +290,6 @@ if opts then
       type = 'idempotent',
       callback = history_save,
       flags = 'empty,explicit_disable,ignore_passthrough',
-      priority = 150,
       augmentations = {string.format("timeout=%f", redis_params.timeout or 0.0)}
     })
     lua_redis.register_prefix(settings.key_prefix .. hostname, N,
diff --git a/src/plugins/lua/metadata_exporter.lua b/src/plugins/lua/metadata_exporter.lua
index c5f4ca148..8ccf9afe1 100644
--- a/src/plugins/lua/metadata_exporter.lua
+++ b/src/plugins/lua/metadata_exporter.lua
@@ -652,7 +652,6 @@ for k, r in pairs(settings.rules) do
     name = 'EXPORT_METADATA_' .. k,
     type = 'idempotent',
     callback = gen_exporter(r),
-    priority = 10,
     flags = 'empty,explicit_disable,ignore_passthrough',
     augmentations = {string.format("timeout=%f", r.timeout or 0.0)}
   })
diff --git a/src/plugins/lua/milter_headers.lua b/src/plugins/lua/milter_headers.lua
index d83115fc5..913b71f54 100644
--- a/src/plugins/lua/milter_headers.lua
+++ b/src/plugins/lua/milter_headers.lua
@@ -692,6 +692,5 @@ rspamd_config:register_symbol({
   name = 'MILTER_HEADERS',
   type = 'idempotent',
   callback = milter_headers,
-  priority = 10,
   flags = 'empty,explicit_disable,ignore_passthrough',
 })
diff --git a/src/plugins/lua/neural.lua b/src/plugins/lua/neural.lua
index d5df56c2b..85894389e 100644
--- a/src/plugins/lua/neural.lua
+++ b/src/plugins/lua/neural.lua
@@ -962,7 +962,6 @@ rspamd_config:register_symbol({
   name = 'NEURAL_LEARN',
   type = 'idempotent,callback',
   flags = 'nostat,explicit_disable,ignore_passthrough',
-  priority = 5,
   callback = ann_push_vector
 })
 
diff --git a/src/plugins/lua/replies.lua b/src/plugins/lua/replies.lua
index ee2e4987f..ef3643f66 100644
--- a/src/plugins/lua/replies.lua
+++ b/src/plugins/lua/replies.lua
@@ -302,7 +302,6 @@ if opts then
       name = 'REPLIES_SET',
       type = 'idempotent',
       callback = replies_set,
-      priority = 5,
       group = 'replies',
       flags = 'explicit_disable,ignore_passthrough',
     })
diff --git a/test/functional/lua/neural.lua b/test/functional/lua/neural.lua
index fb599f3b0..6642d15aa 100644
--- a/test/functional/lua/neural.lua
+++ b/test/functional/lua/neural.lua
@@ -58,7 +58,6 @@ rspamd_config.SAVE_NN_ROW_IDEMPOTENT = {
   end,
   type = 'idempotent',
   flags = 'explicit_disable',
-  priority = 10,
 }
 
 dofile(rspamd_env.INSTALLROOT .. "/share/rspamd/rules/controller/init.lua")


More information about the Commits mailing list