From: Vsevolod Stakhov Date: Sat, 4 May 2019 13:10:51 +0000 (+0100) Subject: [Minor] Allow to get workers count X-Git-Tag: 1.9.3~21 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=02ede418500d0fb27ef3e4cc9c74580b159ccde2;p=rspamd.git [Minor] Allow to get workers count --- 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) {