]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Remove priorities from idempotent filters
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 10 Sep 2022 13:27:15 +0000 (14:27 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 10 Sep 2022 13:27:15 +0000 (14:27 +0100)
12 files changed:
src/libserver/symcache/symcache_impl.cxx
src/libserver/worker_util.c
src/plugins/lua/aws_s3.lua
src/plugins/lua/clickhouse.lua
src/plugins/lua/elastic.lua
src/plugins/lua/greylist.lua
src/plugins/lua/history_redis.lua
src/plugins/lua/metadata_exporter.lua
src/plugins/lua/milter_headers.lua
src/plugins/lua/neural.lua
src/plugins/lua/replies.lua
test/functional/lua/neural.lua

index e7e0a56b079bd75cb9c3643d8b79f2f237e5277e..451222f2ff05855d1dfb31a6acc80f1f6d934d75 100644 (file)
@@ -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;
index 5e296b1d9dd0541f822e1d49526bbb5a2cfdb79c..f9d089a9b9735b5fe2dae1bba6ea6972bc2ec186 100644 (file)
@@ -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);
index 3bce7913c7719fa60ff5bd5ac563fba9a8274553..a1b30e4ed581b4f6abe52de98d1058fc4590ddc0 100644 (file)
@@ -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
index b8f418abd8a3c5da39895f7c1db7a3880fc76038..ce17498743f348c1b6b2002a8db4268700be1816 100644 (file)
@@ -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)},
     })
index 5578d48ec6cdbb2cdd777c25a4c8d63d04570999..8d20720bc51c4743f2e790a5f44ad4630c1bef03 100644 (file)
@@ -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)},
     })
index ae2cd02f90daf389a54272ab7f9718ac53565f6d..04e003a1b879515ca723b5fcc3bd42d318d4db1d 100644 (file)
@@ -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,
index 35bfb9242b4b20a89145506ff221998eaf773517..01645a41049b152f4f173f25f53ed6968e73857d 100644 (file)
@@ -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,
index c5f4ca1485fab38bf5c452c11aeb42da9dc05d20..8ccf9afe153a1aa40e0b2a8bc892b01681253714 100644 (file)
@@ -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)}
   })
index d83115fc5a954c87394ba328c41125651470767e..913b71f5459b5f0ba5194324e245cf8611f5a835 100644 (file)
@@ -692,6 +692,5 @@ rspamd_config:register_symbol({
   name = 'MILTER_HEADERS',
   type = 'idempotent',
   callback = milter_headers,
-  priority = 10,
   flags = 'empty,explicit_disable,ignore_passthrough',
 })
index d5df56c2b07270803774cf52810c93f0541224c3..85894389eda87cbbb48e627790fd30b89b9db740 100644 (file)
@@ -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
 })
 
index ee2e4987f5b633852aa937e755a03ac6ac649e24..ef3643f66a6aaaa02ba166c28951a9b1bc5b932f 100644 (file)
@@ -302,7 +302,6 @@ if opts then
       name = 'REPLIES_SET',
       type = 'idempotent',
       callback = replies_set,
-      priority = 5,
       group = 'replies',
       flags = 'explicit_disable,ignore_passthrough',
     })
index fb599f3b0bf9e482de69ae64bbb78cde5f437453..6642d15aa8b302f998b37f26d7077df022e36d56 100644 (file)
@@ -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")