]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Updated Lua to comply the new call semantic
authorMikhail Galanin <mgalanin@mimecast.com>
Mon, 10 Sep 2018 14:17:14 +0000 (15:17 +0100)
committerMikhail Galanin <mgalanin@mimecast.com>
Mon, 10 Sep 2018 14:17:14 +0000 (15:17 +0100)
lualib/lua_redis.lua
lualib/lua_util.lua
src/plugins/lua/reputation.lua

index 33757b1548acfef9d049304e051d50d54d0a4cf1..3c7bcd3b6789b02317d64306e6571312358438c7 100644 (file)
@@ -961,10 +961,16 @@ end
 
 exports.exec_redis_script = exec_redis_script
 
-local function redis_connect_sync(redis_params, is_write, key, cfg)
+local function redis_connect_sync(redis_params, is_write, key, cfg, ev_base)
   if not redis_params then
     return false,nil
   end
+  if not cfg then
+    cfg = rspamd_config
+  end
+  if not ev_base then
+    ev_base = rspamadm_ev_base
+  end
 
   local rspamd_redis = require "rspamd_redis"
   local addr
@@ -990,8 +996,13 @@ local function redis_connect_sync(redis_params, is_write, key, cfg)
   local options = {
     host = addr:get_addr(),
     timeout = redis_params['timeout'],
+    config = cfg,
+    ev_base = ev_base
   }
 
+  for k,v in pairs(redis_params) do
+    options[k] = v
+  end
 
   local ret,conn = rspamd_redis.connect_sync(options)
   if not ret then
index 0ce0c18748a7a9e6d61f8992c2163c671edb224f..b8e1dbfad58d5b5de6db2049dd32695b1df647cf 100644 (file)
@@ -664,6 +664,30 @@ exports.extract_specific_urls = function(params_or_task, lim, need_emails, filte
   return res
 end
 
+--[[[
+-- @function lua_util.deepcopy(table)
+-- params: {
+- - table
+-- }
+-- Performs deep copy of the table. Including metatables
+--]]
+local function deepcopy(orig)
+  local orig_type = type(orig)
+  local copy
+  if orig_type == 'table' then
+    copy = {}
+    for orig_key, orig_value in next, orig, nil do
+      copy[deepcopy(orig_key)] = deepcopy(orig_value)
+    end
+    setmetatable(copy, deepcopy(getmetatable(orig)))
+  else -- number, string, boolean, etc
+    copy = orig
+  end
+  return copy
+end
+
+exports.deepcopy = deepcopy
+
 -- Debugging support
 local unconditional_debug = false
 local debug_modules = {}
index f5b461d7815c0c84c7ea45f9d7af16d47fc5a586..5d3f64b59f3efacb025083d899f7d227e56c433d 100644 (file)
@@ -996,20 +996,6 @@ local function reputation_idempotent_cb(task, rule)
   end
 end
 
-local function deepcopy(orig)
-  local orig_type = type(orig)
-  local copy
-  if orig_type == 'table' then
-    copy = {}
-    for orig_key, orig_value in next, orig, nil do
-      copy[deepcopy(orig_key)] = deepcopy(orig_value)
-    end
-    setmetatable(copy, deepcopy(getmetatable(orig)))
-  else -- number, string, boolean, etc
-    copy = orig
-  end
-  return copy
-end
 local function override_defaults(def, override)
   for k,v in pairs(override) do
     if k ~= 'selector' and k ~= 'backend' then
@@ -1059,8 +1045,8 @@ local function parse_rule(name, tbl)
   end
   -- Allow config override
   local rule = {
-    selector = deepcopy(selector),
-    backend = deepcopy(backend),
+    selector = lua_util.deepcopy(selector),
+    backend = lua_util.deepcopy(backend),
     config = {}
   }