commit 740a249: [Minor] Fix caching logic

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Aug 28 07:35:06 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-08-27 19:24:26 +0100
URL: https://github.com/rspamd/rspamd/commit/740a249ac32ba14ffec5f80f976120e3dd31bb4d

[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]


More information about the Commits mailing list