Module: kamailio
Branch: 5.2
Commit: 3d9eb0612aa2eec11b75621a3ed630de4a63bf66
URL:
https://github.com/kamailio/kamailio/commit/3d9eb0612aa2eec11b75621a3ed630d…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-03-10T09:21:45+01:00
app_lua: execution log message based on core latency_limit_action
(cherry picked from commit b72996c7b1ad95b89f1b34e849c713bfe3fb50a9)
---
Modified: src/modules/app_lua/app_lua_sr.c
---
Diff:
https://github.com/kamailio/kamailio/commit/3d9eb0612aa2eec11b75621a3ed630d…
Patch:
https://github.com/kamailio/kamailio/commit/3d9eb0612aa2eec11b75621a3ed630d…
---
diff --git a/src/modules/app_lua/app_lua_sr.c b/src/modules/app_lua/app_lua_sr.c
index 89b3a9fd40..65d811a9c1 100644
--- a/src/modules/app_lua/app_lua_sr.c
+++ b/src/modules/app_lua/app_lua_sr.c
@@ -1921,9 +1921,33 @@ int sr_kemi_exec_func(lua_State* L, str *mname, int midx, str
*fname)
int sr_kemi_lua_exec_func(lua_State* L, int eidx)
{
sr_kemi_t *ket;
+ int ret;
+ unsigned int ms = 0;
+ lua_Debug dinfo;
ket = sr_kemi_lua_export_get(eidx);
- return sr_kemi_lua_exec_func_ex(L, ket, 0);
+ if(unlikely(cfg_get(core, core_cfg, latency_limit_action)>0)) {
+ ms = TICKS_TO_MS(get_ticks_raw());
+ }
+
+ ret = sr_kemi_lua_exec_func_ex(L, ket, 0);
+
+ if(unlikely(cfg_get(core, core_cfg, latency_limit_action)>0)) {
+ 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);
+ }
+ }
+
+ return ret;
}
/**