diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-06-15 12:38:14 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-06-15 12:38:14 +0100 |
commit | 97f3650d65c7a359d2218986c680b29ded51e976 (patch) | |
tree | 064f2ecc53b944e174c9dd3ed9ef005c8fe32838 /src/lua/lua_common.c | |
parent | 25931e8fb535905470ef0eb43d2e187a5c5d7783 (diff) | |
download | rspamd-97f3650d65c7a359d2218986c680b29ded51e976.tar.gz rspamd-97f3650d65c7a359d2218986c680b29ded51e976.zip |
[Minor] Lua_config: Add config unload scripts
Diffstat (limited to 'src/lua/lua_common.c')
-rw-r--r-- | src/lua/lua_common.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c index 6ee69c072..a912fb5b5 100644 --- a/src/lua/lua_common.c +++ b/src/lua/lua_common.c @@ -1895,6 +1895,31 @@ rspamd_lua_run_config_post_init (lua_State *L, struct rspamd_config *cfg) } } + +void +rspamd_lua_run_config_unload (lua_State *L, struct rspamd_config *cfg) +{ + struct rspamd_config_cfg_lua_script *sc; + struct rspamd_config **pcfg; + + LL_FOREACH (cfg->post_init_scripts, sc) { + lua_pushcfunction (L, &rspamd_lua_traceback); + gint err_idx = lua_gettop (L); + + lua_rawgeti (L, LUA_REGISTRYINDEX, sc->cbref); + pcfg = lua_newuserdata (L, sizeof (*pcfg)); + *pcfg = cfg; + rspamd_lua_setclass (L, "rspamd{config}", -1); + + if (lua_pcall (L, 1, 0, err_idx) != 0) { + msg_err_config ("cannot run config post init script: %s", + lua_tostring (L, -1)); + } + + lua_settop (L, err_idx - 1); + } +} + static void rspamd_lua_run_postloads_error (struct thread_entry *thread, int ret, const char *msg) { |