]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix id priorities application
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 3 Feb 2020 13:37:08 +0000 (13:37 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 3 Feb 2020 13:37:08 +0000 (13:37 +0000)
src/lua/lua_task.c
src/plugins/lua/settings.lua

index 3855c3cc478a5076db5e16517b9c7d560a73954e..16aa156247f2a2e65fc8e3323392459642441fbb 100644 (file)
@@ -5593,8 +5593,11 @@ lua_task_set_settings_id (lua_State *L)
 
                if (task->settings_elt) {
                        if (task->settings_elt->id != id) {
-                               return luaL_error (L, "settings id has been already set to %d (%s)",
-                                               task->settings_elt->id, task->settings_elt->name);
+                               return luaL_error (L, "settings id has been already set to %d (%s); "
+                                                 "trying to set it to %d",
+                                               task->settings_elt->id,
+                                               task->settings_elt->name,
+                                               id);
                        }
                }
                else {
index be22bf1e5d9c4f184d6b28ebdf144ec1d1d5620a..bc91bf4c8e7fdd0b0786d7a6a671e38243cb45ce 100644 (file)
@@ -253,6 +253,18 @@ local function check_ip_setting(expected, ip)
   return false
 end
 
+local function priority_to_string(pri)
+  if pri then
+    if pri >= 3 then
+      return "high"
+    elseif pri >= 2 then
+      return "medium"
+    end
+  end
+
+  return "low"
+end
+
 -- Check limit for a task
 local function check_settings(task)
   local function check_specific_setting(rule, matched)
@@ -296,20 +308,21 @@ local function check_settings(task)
     if query_apply then
       if id_elt then
         apply_settings(task, query_apply, id_elt.id)
-        rspamd_logger.infox(task, "applied settings id %s(%s)",
-            id_elt.name, id_elt.id)
+        rspamd_logger.infox(task, "applied settings id %s(%s); priority %s",
+            id_elt.name, id_elt.id, priority_to_string(priority))
       else
         apply_settings(task, query_apply, nil)
-        rspamd_logger.infox(task, "applied settings from query")
+        rspamd_logger.infox(task, "applied settings from query; priority %s",
+            priority_to_string(priority))
       end
     end
   end
 
   local min_pri = 1
   if query_apply then
-    if priority > min_pri then
-      -- Do not check lower priorities
-      min_pri = priority
+    if priority >= min_pri then
+      -- Do not check lower or equal priorities
+      min_pri = priority + 1
     end
 
     if priority > max_pri then
@@ -347,10 +360,11 @@ local function check_settings(task)
               if not cached or not cached.settings or not cached.settings.apply then
                 rspamd_logger.errx(task, 'unregistered settings id found: %s!', s.rule.id)
               else
-                rspamd_logger.infox(task, "<%s> apply static settings %s (id = %s); %s matched",
+                rspamd_logger.infox(task, "<%s> apply static settings %s (id = %s); %s matched; priority %s",
                     task:get_message_id(),
                     cached.name, s.rule.id,
-                    table.concat(matched, ','))
+                    table.concat(matched, ','),
+                    priority_to_string(pri))
                 apply_settings(task, cached.settings.apply, s.rule.id)
               end