From 740a249ac32ba14ffec5f80f976120e3dd31bb4d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 27 Aug 2019 19:24:26 +0100 Subject: [PATCH] [Minor] Fix caching logic --- lualib/lua_maps.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua index 23e5cb942..c2f0e406c 100644 --- a/lualib/lua_maps.lua +++ b/lualib/lua_maps.lua @@ -140,8 +140,8 @@ local function rspamd_map_add_from_ucl(opt, mtype, description) elseif type(opt) == 'table' then local k = lua_util.table_digest(opt) if maps_cache[k] then - rspamd_logger.infox(rspamd_config, 'reuse url for %s(%s)', - opt, mtype) + rspamd_logger.infox(rspamd_config, 'reuse url for complex map definition %s: %s', + k:sub(1,8), description) return maps_cache[k] end @@ -155,6 +155,7 @@ local function rspamd_map_add_from_ucl(opt, mtype, description) if map then ret.__data = map setmetatable(ret, ret_mt) + maps_cache[k] = ret return ret end else @@ -167,6 +168,7 @@ local function rspamd_map_add_from_ucl(opt, mtype, description) if map then ret.__data = map setmetatable(ret, ret_mt) + maps_cache[k] = ret return ret end end @@ -181,6 +183,7 @@ local function rspamd_map_add_from_ucl(opt, mtype, description) if map then ret.__data = map setmetatable(ret, ret_mt) + maps_cache[k] = ret return ret end else @@ -195,6 +198,7 @@ local function rspamd_map_add_from_ucl(opt, mtype, description) if map then ret.__data = map setmetatable(ret, ret_mt) + maps_cache[k] = ret return ret end end @@ -209,6 +213,7 @@ local function rspamd_map_add_from_ucl(opt, mtype, description) if map then ret.__data = map setmetatable(ret, ret_mt) + maps_cache[k] = ret return ret end else @@ -247,6 +252,7 @@ local function rspamd_map_add_from_ucl(opt, mtype, description) return nil end + maps_cache[k] = ret return ret else -- Empty map, huh? @@ -265,6 +271,7 @@ local function rspamd_map_add_from_ucl(opt, mtype, description) if map then ret.__data = map setmetatable(ret, ret_mt) + maps_cache[k] = ret return ret end end -- opt[1] -- 2.39.5