From 02ede418500d0fb27ef3e4cc9c74580b159ccde2 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 4 May 2019 14:10:51 +0100 Subject: [PATCH] [Minor] Allow to get workers count --- src/lua/lua_worker.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lua/lua_worker.c b/src/lua/lua_worker.c index 6c73736c8..5c690ce8e 100644 --- a/src/lua/lua_worker.c +++ b/src/lua/lua_worker.c @@ -36,6 +36,7 @@ LUA_FUNCTION_DEF (worker, get_name); LUA_FUNCTION_DEF (worker, get_stat); LUA_FUNCTION_DEF (worker, get_index); +LUA_FUNCTION_DEF (worker, get_count); LUA_FUNCTION_DEF (worker, get_pid); LUA_FUNCTION_DEF (worker, is_scanner); LUA_FUNCTION_DEF (worker, is_primary_controller); @@ -46,6 +47,7 @@ const luaL_reg worker_reg[] = { LUA_INTERFACE_DEF (worker, get_name), LUA_INTERFACE_DEF (worker, get_stat), LUA_INTERFACE_DEF (worker, get_index), + LUA_INTERFACE_DEF (worker, get_count), LUA_INTERFACE_DEF (worker, get_pid), LUA_INTERFACE_DEF (worker, spawn_process), LUA_INTERFACE_DEF (worker, is_scanner), @@ -177,6 +179,21 @@ lua_worker_get_index (lua_State *L) return 1; } +static gint +lua_worker_get_count (lua_State *L) +{ + struct rspamd_worker *w = lua_check_worker (L, 1); + + if (w) { + lua_pushinteger (L, w->cf->count); + } + else { + return luaL_error (L, "invalid arguments"); + } + + return 1; +} + static gint lua_worker_get_pid (lua_State *L) { -- 2.39.5