diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/monitored.c | 2 | ||||
-rw-r--r-- | src/libserver/monitored.h | 8 | ||||
-rw-r--r-- | src/lua/lua_config.c | 19 | ||||
-rw-r--r-- | src/plugins/lua/rbl.lua | 3 |
4 files changed, 31 insertions, 1 deletions
diff --git a/src/libserver/monitored.c b/src/libserver/monitored.c index 7b55b07ec..e1fac6fa1 100644 --- a/src/libserver/monitored.c +++ b/src/libserver/monitored.c @@ -98,7 +98,7 @@ struct rspamd_monitored { INIT_LOG_MODULE(monitored) -static inline void +inline void rspamd_monitored_propagate_error (struct rspamd_monitored *m, const gchar *error) { diff --git a/src/libserver/monitored.h b/src/libserver/monitored.h index 2453a8f48..ce259d176 100644 --- a/src/libserver/monitored.h +++ b/src/libserver/monitored.h @@ -149,6 +149,14 @@ void rspamd_monitored_stop (struct rspamd_monitored *m); void rspamd_monitored_start (struct rspamd_monitored *m); /** + * Propagate external monitored error + * @param m + * @param error + */ +void rspamd_monitored_propagate_error (struct rspamd_monitored *m, + const gchar *error); + +/** * Destroy monitored context and all monitored objects inside * @param ctx */ diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index f42ca268e..fdc572d9d 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -912,12 +912,14 @@ LUA_FUNCTION_DEF (monitored, alive); LUA_FUNCTION_DEF (monitored, latency); LUA_FUNCTION_DEF (monitored, offline); LUA_FUNCTION_DEF (monitored, total_offline); +LUA_FUNCTION_DEF (monitored, propagate_error); static const struct luaL_reg monitoredlib_m[] = { LUA_INTERFACE_DEF (monitored, alive), LUA_INTERFACE_DEF (monitored, latency), LUA_INTERFACE_DEF (monitored, offline), LUA_INTERFACE_DEF (monitored, total_offline), + LUA_INTERFACE_DEF (monitored, propagate_error), {"__tostring", rspamd_lua_class_tostring}, {NULL, NULL} }; @@ -4631,6 +4633,23 @@ lua_monitored_latency (lua_State *L) return 1; } +static gint +lua_monitored_propagate_error (lua_State *L) +{ + LUA_TRACE_POINT; + struct rspamd_monitored *m = lua_check_monitored (L, 1); + const gchar *what = luaL_checkstring (L, 2); + + if (m && what) { + rspamd_monitored_propagate_error (m, what); + } + else { + return luaL_error (L, "invalid arguments"); + } + + return 0; +} + void luaopen_config (lua_State * L) { diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua index f476932b0..fcda1727f 100644 --- a/src/plugins/lua/rbl.lua +++ b/src/plugins/lua/rbl.lua @@ -228,6 +228,9 @@ local function rbl_dns_process(task, rbl, to_resolve, results, err, resolve_tabl rspamd_logger.infox(task, 'error looking up %s: %s', to_resolve, err) task:insert_result(rbl.symbol .. '_FAIL', 1, string.format('%s:%s', resolve_table_elt.orig, err)) + if rbl.monitored then + rbl.monitored:propagate_error(err) + end return end |