aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-04-01 14:22:17 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-04-01 14:22:17 +0100
commit7dfecb9cc8f3ceffaf3a3077166807bfb8fff231 (patch)
treeadb6773e1f66e9dfc02a64d79d1e1fe5a66b7956 /src
parent302da75c22217d0c8c0a6a868b85e81df8f63dd0 (diff)
downloadrspamd-7dfecb9cc8f3ceffaf3a3077166807bfb8fff231.tar.gz
rspamd-7dfecb9cc8f3ceffaf3a3077166807bfb8fff231.zip
[Fix] Another fix for Redis sentinel
Issue: #2796
Diffstat (limited to 'src')
-rw-r--r--src/libserver/cfg_rcl.c2
-rw-r--r--src/lua/lua_common.c14
-rw-r--r--src/plugins/lua/bayes_expiry.lua11
-rw-r--r--src/plugins/lua/reputation.lua5
4 files changed, 17 insertions, 15 deletions
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 5c99aed59..ed99ef8b6 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -3554,7 +3554,7 @@ rspamd_rcl_jinja_handler (struct ucl_parser *parser,
GString *tb;
tb = lua_touserdata (L, -1);
- msg_err_config ("cannot call lua try_load_redis_servers script: %s", tb->str);
+ msg_err_config ("cannot call lua jinja_template script: %s", tb->str);
g_string_free (tb, TRUE);
lua_settop (L, err_idx - 1);
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index 5f1be424d..81fac3640 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -2500,12 +2500,9 @@ gboolean
rspamd_lua_try_load_redis (lua_State *L, const ucl_object_t *obj,
struct rspamd_config *cfg, gint *ref_id)
{
- gint res_pos, err_idx;
+ gint err_idx;
struct rspamd_config **pcfg;
- /* Create results table */
- lua_createtable (L, 0, 0);
- res_pos = lua_gettop (L);
lua_pushcfunction (L, &rspamd_lua_traceback);
err_idx = lua_gettop (L);
@@ -2522,7 +2519,7 @@ rspamd_lua_try_load_redis (lua_State *L, const ucl_object_t *obj,
pcfg = lua_newuserdata (L, sizeof (*pcfg));
rspamd_lua_setclass (L, "rspamd{config}", -1);
*pcfg = cfg;
- lua_pushvalue (L, res_pos);
+ lua_pushboolean (L, false); /* no_fallback */
if (lua_pcall (L, 3, 1, err_idx) != 0) {
GString *tb;
@@ -2535,16 +2532,17 @@ rspamd_lua_try_load_redis (lua_State *L, const ucl_object_t *obj,
return FALSE;
}
- if (lua_toboolean (L, -1)) {
+ if (lua_istable (L, -1)) {
if (ref_id) {
/* Ref table */
- lua_pushvalue (L, res_pos);
+ lua_pushvalue (L, -1);
*ref_id = luaL_ref (L, LUA_REGISTRYINDEX);
lua_settop (L, 0);
}
else {
/* Leave it on the stack */
- lua_settop (L, res_pos);
+ lua_insert (L, err_idx);
+ lua_settop (L, err_idx);
}
return TRUE;
diff --git a/src/plugins/lua/bayes_expiry.lua b/src/plugins/lua/bayes_expiry.lua
index 9f5d7a68f..6e2c328dc 100644
--- a/src/plugins/lua/bayes_expiry.lua
+++ b/src/plugins/lua/bayes_expiry.lua
@@ -97,10 +97,13 @@ local function check_redis_classifier(cls, cfg)
end
-- Now try to load redis_params if needed
- local redis_params = {}
- if not lredis.try_load_redis_servers(cls, rspamd_config, redis_params) then
- if not lredis.try_load_redis_servers(cfg[N] or E, rspamd_config, redis_params) then
- if not lredis.try_load_redis_servers(cfg['redis'] or E, rspamd_config, redis_params) then
+ local redis_params
+ redis_params = lredis.try_load_redis_servers(cls, rspamd_config, false, 'bayes')
+ if not redis_params then
+ redis_params = lredis.try_load_redis_servers(cfg[N] or E, rspamd_config, false, 'bayes')
+ if not redis_params then
+ redis_params = lredis.try_load_redis_servers(cfg[N] or E, rspamd_config, true)
+ if not redis_params then
return false
end
end
diff --git a/src/plugins/lua/reputation.lua b/src/plugins/lua/reputation.lua
index e91c6ebb7..b72c00719 100644
--- a/src/plugins/lua/reputation.lua
+++ b/src/plugins/lua/reputation.lua
@@ -897,8 +897,9 @@ end
local function reputation_redis_init(rule, cfg, ev_base, worker)
local our_redis_params = {}
- if not lua_redis.try_load_redis_servers(rule.backend.config,
- rspamd_config, our_redis_params) then
+ our_redis_params = lua_redis.try_load_redis_servers(rule.backend.config, rspamd_config,
+ true)
+ if not our_redis_params then
our_redis_params = redis_params
end
if not our_redis_params then