summaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/ratelimit.lua
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2016-11-16 16:06:36 +0200
committerAndrew Lewis <nerf@judo.za.org>2016-11-16 16:06:36 +0200
commit16f2de7c829fddc4525c99059f7064748ec7ff3a (patch)
tree485c0c1f79b1cef494974e8d6c21b621b5b84d44 /src/plugins/lua/ratelimit.lua
parenta198fea999bc5a35ef8c96236dc007fe69861dda (diff)
downloadrspamd-16f2de7c829fddc4525c99059f7064748ec7ff3a.tar.gz
rspamd-16f2de7c829fddc4525c99059f7064748ec7ff3a.zip
[Minor] Move upstream handling into rspamd_redis_make_request
Diffstat (limited to 'src/plugins/lua/ratelimit.lua')
-rw-r--r--src/plugins/lua/ratelimit.lua13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua
index f15d8633e..1a7bdf222 100644
--- a/src/plugins/lua/ratelimit.lua
+++ b/src/plugins/lua/ratelimit.lua
@@ -207,14 +207,11 @@ end
local function check_limits(task, args)
local key = fun.foldl(function(acc, k) return acc .. k[2] end, '', args)
- local ret,upstream
+ local ret
--- Called when value is got from server
local function rate_get_cb(err, data)
if err then
rspamd_logger.infox(task, 'got error while getting limit: %1', err)
- upstream:fail()
- else
- upstream:ok()
end
if not data then return end
local ntime = rspamd_util.get_time()
@@ -298,8 +295,7 @@ local function check_limits(task, args)
fun.map(function(a) return rspamd_str_split(a[2], ":")[2] end, args)))
end
- local _
- ret,_,upstream = rspamd_redis_make_request(task,
+ ret = rspamd_redis_make_request(task,
redis_params, -- connect params
key, -- hash key
false, -- is write
@@ -318,9 +314,7 @@ local function set_limits(task, args)
local ret, upstream
local function rate_set_cb(err)
- if not err then
- upstream:ok()
- else
+ if err then
rspamd_logger.infox(task, 'got error %s when setting ratelimit record on server %s',
err, upstream:get_addr())
end
@@ -328,7 +322,6 @@ local function set_limits(task, args)
local function rate_get_cb(err, data)
if err then
rspamd_logger.infox(task, 'got error while setting limit: %1', err)
- upstream:fail()
end
if not data then return end
local ntime = rspamd_util.get_time()