summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-07-27 14:57:22 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-07-27 14:57:22 +0100
commitb17a9e51c64883a04d1a8a6e3e3aeb752e4aa1a1 (patch)
treeca02e51edb85b74cd48d16ba12f39e266a245ea5
parentd5e76f0a91f566576e9b5daf4aac3b07bd9324c3 (diff)
downloadrspamd-b17a9e51c64883a04d1a8a6e3e3aeb752e4aa1a1.tar.gz
rspamd-b17a9e51c64883a04d1a8a6e3e3aeb752e4aa1a1.zip
[Fix] Avoid race between config new/free by using a counter
-rw-r--r--src/lua/lua_common.c8
1 files 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)