aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Galanin <mgalanin@mimecast.com>2018-10-01 10:41:51 +0100
committerMikhail Galanin <mgalanin@mimecast.com>2018-10-01 10:41:51 +0100
commit4dfe49bc169346ae120bafbda643f0477886da41 (patch)
tree0094428fae6189ab1a6b5b38333634dc02402038
parent5c8208c6972fb0e5880836b7957cf7dd63ac0897 (diff)
downloadrspamd-4dfe49bc169346ae120bafbda643f0477886da41.tar.gz
rspamd-4dfe49bc169346ae120bafbda643f0477886da41.zip
[Minor] Fixed sync redis connection with default arguments in rspamadm
-rw-r--r--lualib/lua_redis.lua26
-rw-r--r--test/functional/lua/rspamadm/test_redis_client.lua6
2 files changed, 21 insertions, 11 deletions
diff --git a/lualib/lua_redis.lua b/lualib/lua_redis.lua
index 92ff4cc12..e95981c82 100644
--- a/lualib/lua_redis.lua
+++ b/lualib/lua_redis.lua
@@ -997,12 +997,6 @@ 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
@@ -1028,14 +1022,30 @@ local function redis_connect_sync(redis_params, is_write, key, cfg, ev_base)
local options = {
host = addr:get_addr(),
timeout = redis_params['timeout'],
- config = cfg,
- ev_base = ev_base
+ config = cfg or rspamd_config,
+ ev_base = ev_base or rspamadm_ev_base,
+ session = redis_params.session or rspamadm_session
}
for k,v in pairs(redis_params) do
options[k] = v
end
+ if not options.config then
+ logger.errx('config is not set')
+ return false,nil,addr
+ end
+
+ if not options.ev_base then
+ logger.errx('ev_base is not set')
+ return false,nil,addr
+ end
+
+ if not options.session then
+ logger.errx('session is not set')
+ return false,nil,addr
+ end
+
local ret,conn = rspamd_redis.connect_sync(options)
if not ret then
logger.errx('cannot execute redis request: %s', conn)
diff --git a/test/functional/lua/rspamadm/test_redis_client.lua b/test/functional/lua/rspamadm/test_redis_client.lua
index 7de82cd96..a7428a807 100644
--- a/test/functional/lua/rspamadm/test_redis_client.lua
+++ b/test/functional/lua/rspamadm/test_redis_client.lua
@@ -8,9 +8,9 @@ local upstreams_read = upstream_list.create('127.0.0.1', 56379)
local is_ok, connection = redis.redis_connect_sync({
write_servers = upstreams_write,
read_servers = upstreams_read,
- config = rspamd_config,
- ev_base = rspamadm_ev_base,
- session = rspamadm_session,
+-- config = rspamd_config,
+-- ev_base = rspamadm_ev_base,
+-- session = rspamadm_session,
timeout = 2
})