diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-05-20 20:51:28 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-05-20 20:51:28 +0100 |
commit | fd5a976a094df481896172e6b3e1780958f2beaa (patch) | |
tree | b08c0eb9ec5a9360fb56ca4d0326406076e085f8 | |
parent | 48036e40210693fbe552016bfe0deb35796438af (diff) | |
download | rspamd-fd5a976a094df481896172e6b3e1780958f2beaa.tar.gz rspamd-fd5a976a094df481896172e6b3e1780958f2beaa.zip |
[Minor] Improve functions pcall invocations
-rw-r--r-- | src/lua/lua_map.c | 14 | ||||
-rw-r--r-- | src/lua/lua_redis.c | 7 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/lua/lua_map.c b/src/lua/lua_map.c index a5defd011..25e7bdc92 100644 --- a/src/lua/lua_map.c +++ b/src/lua/lua_map.c @@ -442,6 +442,10 @@ lua_map_fin (struct map_cb_data *data, void **target) msg_err_map ("map has no callback set"); } else if (cbdata->data != NULL && cbdata->data->len != 0) { + + lua_pushcfunction (cbdata->L, &rspamd_lua_traceback); + int err_idx = lua_gettop (cbdata->L); + lua_rawgeti (cbdata->L, LUA_REGISTRYINDEX, cbdata->ref); if (!cbdata->opaque) { @@ -461,11 +465,15 @@ lua_map_fin (struct map_cb_data *data, void **target) *pmap = cbdata->lua_map; rspamd_lua_setclass (cbdata->L, "rspamd{map}", -1); - if (lua_pcall (cbdata->L, 2, 0, 0) != 0) { - msg_info_map ("call to %s failed: %s", "local function", + gint ret = lua_pcall (cbdata->L, 2, 0, err_idx); + + if (ret != 0) { + msg_info_map ("call to %s failed (%d): %s", "map fin function", + ret, lua_tostring (cbdata->L, -1)); - lua_pop (cbdata->L, 1); } + + lua_settop (cbdata->L, err_idx - 1); } cbdata->data = rspamd_fstring_assign (cbdata->data, "", 0); diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c index 492c63906..ab76c3114 100644 --- a/src/lua/lua_redis.c +++ b/src/lua/lua_redis.c @@ -405,8 +405,11 @@ lua_redis_push_data (const redisReply *r, struct lua_redis_ctx *ctx, rspamd_symcache_set_cur_item (ud->task, ud->item); } - if (lua_pcall (cbs.L, 2, 0, err_idx) != 0) { - msg_info ("call to callback failed: %s", lua_tostring (cbs.L, -1)); + gint ret = lua_pcall (cbs.L, 2, 0, err_idx); + + if (ret != 0) { + msg_info ("call to lua_redis callback failed (%d): %s", + ret, lua_tostring (cbs.L, -1)); } lua_settop (L, err_idx - 1); |