commit 02ede41: [Minor] Allow to get workers count
Vsevolod Stakhov
vsevolod at highsecure.ru
Sat May 4 13:14:11 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-05-04 14:10:51 +0100
URL: https://github.com/rspamd/rspamd/commit/02ede418500d0fb27ef3e4cc9c74580b159ccde2 (HEAD -> master)
[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)
{
More information about the Commits
mailing list