aboutsummaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-28 14:15:46 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-28 14:15:46 +0000
commit9d7ebd2f71851186df50aebc0cb86b540402d5a6 (patch)
tree3dc08eefb233a9cecc1aa7a0533d892a8450c2a3 /lualib
parentd43d9b9a3b9ed044f8e208bc2cb08f4f11f61b6c (diff)
downloadrspamd-9d7ebd2f71851186df50aebc0cb86b540402d5a6.tar.gz
rspamd-9d7ebd2f71851186df50aebc0cb86b540402d5a6.zip
[Minor] Fix dealing with argv in scripts
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_redis.lua19
1 files changed, 11 insertions, 8 deletions
diff --git a/lualib/lua_redis.lua b/lualib/lua_redis.lua
index ceb997c33..e79534c6f 100644
--- a/lualib/lua_redis.lua
+++ b/lualib/lua_redis.lua
@@ -844,7 +844,7 @@ end
exports.add_redis_script = add_redis_script
local function exec_redis_script(id, params, callback, keys, args)
- local keys_modified = false
+ local redis_args = {}
if not redis_scripts[id] then
logger.errx("cannot find registered script with id %s", id)
@@ -878,26 +878,29 @@ local function exec_redis_script(id, params, callback, keys, args)
end
end
- if not keys_modified then
- table.insert(keys, 1, tostring(#keys))
- table.insert(keys, 1, script.sha)
+ if #redis_args == 0 then
+ table.insert(redis_args, script.sha)
+ table.insert(redis_args, tostring(#keys))
+ for _,k in ipairs(keys) do
+ table.insert(redis_args, k)
+ end
+
if type(args) == 'table' then
for _, a in ipairs(args) do
- table.insert(keys, a)
+ table.insert(redis_args, a)
end
end
- keys_modified = true
end
if params.task then
if not rspamd_redis_make_request(params.task, script.redis_params,
- params.key, params.is_write, redis_cb, 'EVALSHA', keys) then
+ params.key, params.is_write, redis_cb, 'EVALSHA', redis_args) then
callback('Cannot make redis request', nil)
end
else
if not redis_make_request_taskless(params.ev_base, rspamd_config,
script.redis_params,
- params.key, params.is_write, redis_cb, 'EVALSHA', keys) then
+ params.key, params.is_write, redis_cb, 'EVALSHA', redis_args) then
callback('Cannot make redis request', nil)
end
end