diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-24 15:44:28 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-24 15:44:28 +0000 |
commit | 951bc1990f5251dfe6a5cdcdb047f4697e09c7b9 (patch) | |
tree | 3d1179ac88e4f0f0778ef14579609a5c59197260 /src/lua/lua_common.c | |
parent | 06f00fda88ec36977d370933803a15ec7059a17f (diff) | |
download | rspamd-951bc1990f5251dfe6a5cdcdb047f4697e09c7b9.tar.gz rspamd-951bc1990f5251dfe6a5cdcdb047f4697e09c7b9.zip |
[Minor] Add traceback on postload executions
Diffstat (limited to 'src/lua/lua_common.c')
-rw-r--r-- | src/lua/lua_common.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c index 1b4f3e8c7..15e26beda 100644 --- a/src/lua/lua_common.c +++ b/src/lua/lua_common.c @@ -1258,9 +1258,14 @@ rspamd_lua_run_postloads (lua_State *L, struct rspamd_config *cfg, struct rspamd_config **pcfg; struct event_base **pev_base; struct rspamd_worker **pw; + gint err_idx; + GString *tb; /* Execute post load scripts */ LL_FOREACH (cfg->on_load, sc) { + lua_pushcfunction (L, &rspamd_lua_traceback); + err_idx = lua_gettop (L); + lua_rawgeti (cfg->lua_state, LUA_REGISTRYINDEX, sc->cbref); pcfg = lua_newuserdata (cfg->lua_state, sizeof (*pcfg)); *pcfg = cfg; @@ -1274,13 +1279,16 @@ rspamd_lua_run_postloads (lua_State *L, struct rspamd_config *cfg, *pw = w; rspamd_lua_setclass (cfg->lua_state, "rspamd{worker}", -1); - if (lua_pcall (cfg->lua_state, 3, 0, 0) != 0) { - msg_err_config ("error executing post load code: %s", - lua_tostring (cfg->lua_state, -1)); - lua_pop (cfg->lua_state, 1); + if (lua_pcall (cfg->lua_state, 3, 0, err_idx) != 0) { + tb = lua_touserdata (L, -1); + msg_err_config ("error executing post load code: %v", tb); + g_string_free (tb, TRUE); + lua_pop (L, 2); return FALSE; } + + lua_pop (L, 1); /* Error function */ } return TRUE; |