Module: kamailio
Branch: 5.2
Commit: c108904cee314e8b3c2c1d0382a0830a9b2796df
URL:
https://github.com/kamailio/kamailio/commit/c108904cee314e8b3c2c1d0382a0830…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-03-28T19:22:15+01:00
app_lua: use lua_getstack() to init structure for debug info
(cherry picked from commit 47cde53eb257898c25212523d013bd7e74a30b28)
---
Modified: src/modules/app_lua/app_lua_sr.c
---
Diff:
https://github.com/kamailio/kamailio/commit/c108904cee314e8b3c2c1d0382a0830…
Patch:
https://github.com/kamailio/kamailio/commit/c108904cee314e8b3c2c1d0382a0830…
---
diff --git a/src/modules/app_lua/app_lua_sr.c b/src/modules/app_lua/app_lua_sr.c
index 65d811a9c1..5baa1a368e 100644
--- a/src/modules/app_lua/app_lua_sr.c
+++ b/src/modules/app_lua/app_lua_sr.c
@@ -1936,14 +1936,25 @@ int sr_kemi_lua_exec_func(lua_State* L, int eidx)
ms = TICKS_TO_MS(get_ticks_raw()) - ms;
if(ms >= cfg_get(core, core_cfg, latency_limit_action)
&& is_printable(cfg_get(core, core_cfg, latency_log))) {
- lua_getinfo(L, "nSl", &dinfo);
- LOG(cfg_get(core, core_cfg, latency_log),
- "alert - action KSR.%s%s%s(...)"
- " took too long [%u ms] (%s:%d - %s [%s])\n",
- (ket->mname.len>0)?ket->mname.s:"",
- (ket->mname.len>0)?".":"", ket->fname.s, ms,
- dinfo.short_src, dinfo.currentline,
- (dinfo.name?dinfo.name:"<unknown>"), dinfo.what);
+ memset(&dinfo, 0, sizeof(lua_Debug));
+ if(lua_getstack(L, 0, &dinfo)==0
+ && lua_getinfo(L, "nSl", &dinfo)==0) {
+ LOG(cfg_get(core, core_cfg, latency_log),
+ "alert - action KSR.%s%s%s(...)"
+ " took too long [%u ms] (%s:%d - %s [%s])\n",
+ (ket->mname.len>0)?ket->mname.s:"",
+ (ket->mname.len>0)?".":"", ket->fname.s, ms,
+ (dinfo.short_src[0])?dinfo.short_src:"<unknown>",
+ dinfo.currentline,
+ (dinfo.name)?dinfo.name:"<unknown>",
+ (dinfo.what)?dinfo.what:"<unknown>");
+ } else {
+ LOG(cfg_get(core, core_cfg, latency_log),
+ "alert - action KSR.%s%s%s(...)"
+ " took too long [%u ms]\n",
+ (ket->mname.len>0)?ket->mname.s:"",
+ (ket->mname.len>0)?".":"", ket->fname.s, ms);
+ }
}
}