commit b17a9e5: [Fix] Avoid race between config new/free by using a counter
Vsevolod Stakhov
vsevolod at rspamd.com
Thu Jul 27 14:00:03 UTC 2023
Author: Vsevolod Stakhov
Date: 2023-07-27 14:57:22 +0100
URL: https://github.com/rspamd/rspamd/commit/b17a9e51c64883a04d1a8a6e3e3aeb752e4aa1a1 (HEAD -> master)
[Fix] Avoid race between config new/free by using a counter
---
src/lua/lua_common.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index c05b4346a..b543ae5db 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -908,7 +908,7 @@ rspamd_lua_wipe_realloc(void *ud,
extern int luaopen_bit(lua_State *L);
#endif
-static bool lua_initialized = false;
+static unsigned int lua_initialized = 0;
lua_State *
rspamd_lua_init(bool wipe_mem)
@@ -1032,7 +1032,7 @@ rspamd_lua_init(bool wipe_mem)
lua_setglobal(L, "get_traces");
#endif
- lua_initialized = true;
+ lua_initialized++;
return L;
}
@@ -1058,12 +1058,12 @@ void rspamd_lua_close(lua_State *L)
kh_destroy(lua_class_set, ctx->classes);
g_free(ctx);
- lua_initialized = false;
+ lua_initialized--;
}
bool rspamd_lua_is_initialised(void)
{
- return lua_initialized;
+ return lua_initialized != 0;
}
void rspamd_lua_start_gc(struct rspamd_config *cfg)
More information about the Commits
mailing list