aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_common.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-26 16:04:58 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-26 16:04:58 +0000
commit714ebee786d239c68aff8356b199eca9d14b8794 (patch)
treeb831f711c9c40e6675770ed45a8e7c5fa15d06d3 /src/lua/lua_common.c
parent4d386d0c689ad4607c67dcd634e53aadea940613 (diff)
downloadrspamd-714ebee786d239c68aff8356b199eca9d14b8794.tar.gz
rspamd-714ebee786d239c68aff8356b199eca9d14b8794.zip
[Minor] Add common methods to find a primary controller
Diffstat (limited to 'src/lua/lua_common.c')
-rw-r--r--src/lua/lua_common.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index f61fa6d0b..942f5a9b6 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -38,6 +38,7 @@ LUA_FUNCTION_DEF (worker, get_stat);
LUA_FUNCTION_DEF (worker, get_index);
LUA_FUNCTION_DEF (worker, get_pid);
LUA_FUNCTION_DEF (worker, is_scanner);
+LUA_FUNCTION_DEF (worker, is_primary_controller);
LUA_FUNCTION_DEF (worker, spawn_process);
const luaL_reg worker_reg[] = {
@@ -47,6 +48,7 @@ const luaL_reg worker_reg[] = {
LUA_INTERFACE_DEF (worker, get_pid),
LUA_INTERFACE_DEF (worker, spawn_process),
LUA_INTERFACE_DEF (worker, is_scanner),
+ LUA_INTERFACE_DEF (worker, is_primary_controller),
{"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -1449,6 +1451,21 @@ lua_worker_is_scanner (lua_State *L)
return 1;
}
+static gint
+lua_worker_is_primary_controller (lua_State *L)
+{
+ struct rspamd_worker *w = lua_check_worker (L, 1);
+
+ if (w) {
+ lua_pushboolean (L, rspamd_worker_is_primary_controller (w));
+ }
+ else {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ return 1;
+}
+
struct rspamd_lua_process_cbdata {
gint sp[2];
gint func_cbref;