commit d9180d3: [Minor] Remove static settings pool (cfg pool is good enough)

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Jan 12 14:00:07 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-01-12 12:31:33 +0000
URL: https://github.com/rspamd/rspamd/commit/d9180d3ac0fac6d0aa12cd33117cb7efc731e2a2

[Minor] Remove static settings pool (cfg pool is good enough)

---
 src/plugins/lua/settings.lua | 25 +++++--------------------
 1 file changed, 5 insertions(+), 20 deletions(-)

diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua
index 81b328b52..56a9f5079 100644
--- a/src/plugins/lua/settings.lua
+++ b/src/plugins/lua/settings.lua
@@ -31,7 +31,6 @@ local lua_selectors = require "lua_selectors"
 local lua_settings = require "lua_settings"
 local ucl = require "ucl"
 local fun = require "fun"
-local rspamd_mempool = require "rspamd_mempool"
 
 local redis_params
 
@@ -395,7 +394,7 @@ local function check_settings(task)
 end
 
 -- Process settings based on their priority
-local function process_settings_table(tbl, allow_ids, mempool, is_static)
+local function process_settings_table(tbl, allow_ids, is_static)
   local get_priority = function(elt)
     local pri_tonum = function(p)
       if p then
@@ -923,7 +922,7 @@ local function process_settings_table(tbl, allow_ids, mempool, is_static)
 
       local rspamd_expression = require "rspamd_expression"
       out.expression = rspamd_expression.create(elt.expression, parse_atom,
-          mempool)
+          rspamd_config:get_mempool())
       out.checks = checks
 
       if not out.expression then
@@ -1041,7 +1040,6 @@ local function process_settings_table(tbl, allow_ids, mempool, is_static)
 end
 
 -- Parse settings map from the ucl line
-local settings_map_pool
 local function process_settings_map(map_text)
   local parser = ucl.parser()
   local res,err
@@ -1055,17 +1053,11 @@ local function process_settings_map(map_text)
   if not res then
     rspamd_logger.warnx(rspamd_config, 'cannot parse settings map: ' .. err)
   else
-    if settings_map_pool then
-      settings_map_pool:destroy()
-    end
-
-    settings_map_pool = rspamd_mempool.create()
-
     local obj = parser:get_object()
     if obj['settings'] then
-      process_settings_table(obj['settings'], false, settings_map_pool)
+      process_settings_table(obj['settings'], false, false)
     else
-      process_settings_table(obj, false, settings_map_pool)
+      process_settings_table(obj, false, false)
     end
   end
 
@@ -1185,7 +1177,6 @@ if set_section and set_section[1] and type(set_section[1]) == "string" then
     rspamd_logger.errx(rspamd_config, 'cannot load settings from %1', set_section)
   end
 elseif set_section and type(set_section) == "table" then
-  settings_map_pool = rspamd_mempool.create()
   -- We need to check this table and register static symbols first
   -- Postponed settings init is needed to ensure that all symbols have been
   -- registered BEFORE settings plugin. Otherwise, we can have inconsistent settings expressions
@@ -1216,12 +1207,6 @@ elseif set_section and type(set_section) == "table" then
           end, set_section)
   )
   rspamd_config:add_post_init(function ()
-    process_settings_table(set_section, true, settings_map_pool, true)
+    process_settings_table(set_section, true, true)
   end, 100)
 end
-
-rspamd_config:add_config_unload(function()
-  if settings_map_pool then
-    settings_map_pool:destroy()
-  end
-end)


More information about the Commits mailing list