]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Allow to get workers count
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 4 May 2019 13:10:51 +0000 (14:10 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 4 May 2019 13:10:51 +0000 (14:10 +0100)
src/lua/lua_worker.c

index 6c73736c80d1591daae1bc5e0f87770737e3cb9b..5c690ce8ebd4e52d9b0525d2a90bb3d3fd66ab11 100644 (file)
@@ -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)
 {