commit 00c1542: [Fix] Try to move setings initialisation to a later stage

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Dec 28 20:42:07 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-12-28 20:39:43 +0000
URL: https://github.com/rspamd/rspamd/commit/00c154271407b00de368dfc91e6d1cb857a0d712 (HEAD -> master)

[Fix] Try to move setings initialisation to a later stage

---
 lualib/lua_settings.lua      | 12 ++++++------
 src/plugins/lua/settings.lua |  4 +++-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/lualib/lua_settings.lua b/lualib/lua_settings.lua
index b08b8c14e..5779cea85 100644
--- a/lualib/lua_settings.lua
+++ b/lualib/lua_settings.lua
@@ -31,7 +31,7 @@ local fun = require "fun"
 local lua_util = require "lua_util"
 local rspamd_logger = require "rspamd_logger"
 
-local function register_settings_cb()
+local function register_settings_cb(from_postload)
   if not post_init_performed then
     all_symbols = rspamd_config:get_symbols()
 
@@ -249,7 +249,7 @@ local function register_settings_id(str, settings)
   end
 
   if not post_init_added then
-    rspamd_config:add_post_init(register_settings_cb)
+    rspamd_config:add_post_init(function () register_settings_cb(true) end)
     rspamd_config:add_config_unload(function()
       if post_init_added then
         known_ids = {}
@@ -269,7 +269,7 @@ exports.register_settings_id = register_settings_id
 
 local function settings_by_id(id)
   if not post_init_performed then
-    register_settings_cb()
+    register_settings_cb(false)
   end
   return known_ids[id]
 end
@@ -278,20 +278,20 @@ end
 exports.settings_by_id = settings_by_id
 exports.all_settings = function()
   if not post_init_performed then
-    register_settings_cb()
+    register_settings_cb(false)
   end
   return known_ids
 end
 exports.all_symbols = function()
   if not post_init_performed then
-    register_settings_cb()
+    register_settings_cb(false)
   end
   return all_symbols
 end
 -- What is enabled when no settings are there
 exports.default_symbols = function()
   if not post_init_performed then
-    register_settings_cb()
+    register_settings_cb(false)
   end
   return default_symbols
 end
diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua
index f9e3e2524..8dfd91c10 100644
--- a/src/plugins/lua/settings.lua
+++ b/src/plugins/lua/settings.lua
@@ -1180,7 +1180,9 @@ if set_section and set_section[1] and type(set_section[1]) == "string" then
   end
 elseif set_section and type(set_section) == "table" then
   settings_map_pool = rspamd_mempool.create()
-  process_settings_table(set_section, true, settings_map_pool)
+  rspamd_config:add_post_init(function ()
+    process_settings_table(set_section, true, settings_map_pool)
+  end)
 end
 
 rspamd_config:add_config_unload(function()


More information about the Commits mailing list