Module: kamailio
Branch: 5.2
Commit: f10181b47b4365e8b873d2c8e09f844be25eb865
URL:
https://github.com/kamailio/kamailio/commit/f10181b47b4365e8b873d2c8e09f844…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-03-10T09:22:06+01:00
app_jsdt: execution log message based on core latency_limit_action
(cherry picked from commit 4d5622b25039a0b35ae3e6d447843d3fb33af334)
---
Modified: src/modules/app_jsdt/app_jsdt_api.c
---
Diff:
https://github.com/kamailio/kamailio/commit/f10181b47b4365e8b873d2c8e09f844…
Patch:
https://github.com/kamailio/kamailio/commit/f10181b47b4365e8b873d2c8e09f844…
---
diff --git a/src/modules/app_jsdt/app_jsdt_api.c b/src/modules/app_jsdt/app_jsdt_api.c
index b542355172..7d55804623 100644
--- a/src/modules/app_jsdt/app_jsdt_api.c
+++ b/src/modules/app_jsdt/app_jsdt_api.c
@@ -1336,9 +1336,34 @@ int sr_kemi_jsdt_exec_func_ex(duk_context *J, sr_kemi_t *ket)
int sr_kemi_jsdt_exec_func(duk_context *J, int eidx)
{
sr_kemi_t *ket;
+ int ret;
+ unsigned int ms = 0;
+ int sline = 0;
ket = sr_kemi_jsdt_export_get(eidx);
- return sr_kemi_jsdt_exec_func_ex(J, ket);
+ if(unlikely(cfg_get(core, core_cfg, latency_limit_action)>0)) {
+ ms = TICKS_TO_MS(get_ticks_raw());
+ }
+
+ ret = sr_kemi_jsdt_exec_func_ex(J, ket);
+
+ 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))) {
+ duk_inspect_callstack_entry(J, -1);
+ duk_get_prop_string(J, -1, "lineNumber");
+ sline = (int)duk_to_int(J, -1);
+ duk_pop_2(J);
+ LOG(cfg_get(core, core_cfg, latency_log),
+ "alert - action KSR.%s%s%s(...)"
+ " took too long [%u ms] (line: %d)\n",
+ (ket->mname.len>0)?ket->mname.s:"",
+ (ket->mname.len>0)?".":"", ket->fname.s, ms, sline);
+ }
+ }
+
+ return ret;
}
/**