|
@@ -23,6 +23,7 @@
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
#include <Python.h>
|
|
|
+#include <frameobject.h>
|
|
|
|
|
|
#include "../../core/dprint.h"
|
|
|
#include "../../core/route.h"
|
|
@@ -30,6 +31,7 @@
|
|
|
#include "../../core/kemi.h"
|
|
|
#include "../../core/locking.h"
|
|
|
#include "../../core/pvar.h"
|
|
|
+#include "../../core/timer.h"
|
|
|
#include "../../core/mem/pkg.h"
|
|
|
#include "../../core/mem/shm.h"
|
|
|
#include "../../core/rpc.h"
|
|
@@ -166,12 +168,11 @@ PyObject *sr_apy_kemi_return_str(sr_kemi_t *ket, char *sval, int slen)
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
-PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
|
|
|
+PyObject *sr_apy_kemi_exec_func_ex(sr_kemi_t *ket, PyObject *self, PyObject *args, int idx)
|
|
|
{
|
|
|
str fname;
|
|
|
int i;
|
|
|
int ret;
|
|
|
- sr_kemi_t *ket = NULL;
|
|
|
sr_kemi_val_t vps[SR_KEMI_PARAMS_MAX];
|
|
|
sr_apy_env_t *env_P;
|
|
|
sip_msg_t *lmsg = NULL;
|
|
@@ -188,10 +189,6 @@ PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
|
|
|
lmsg = env_P->msg;
|
|
|
}
|
|
|
|
|
|
- ket = sr_apy_kemi_export_get(idx);
|
|
|
- if(ket==NULL) {
|
|
|
- return sr_kemi_apy_return_false();
|
|
|
- }
|
|
|
if(ket->mname.len>0) {
|
|
|
LM_DBG("execution of method: %.*s\n", ket->fname.len, ket->fname.s);
|
|
|
} else {
|
|
@@ -724,6 +721,50 @@ PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ *
|
|
|
+ */
|
|
|
+PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
|
|
|
+{
|
|
|
+ sr_kemi_t *ket = NULL;
|
|
|
+ PyObject *ret = NULL;
|
|
|
+ unsigned int ms = 0;
|
|
|
+ PyThreadState *pstate = NULL;
|
|
|
+ PyFrameObject *pframe = NULL;
|
|
|
+
|
|
|
+ ket = sr_apy_kemi_export_get(idx);
|
|
|
+ if(ket==NULL) {
|
|
|
+ return sr_kemi_apy_return_false();
|
|
|
+ }
|
|
|
+ if(unlikely(cfg_get(core, core_cfg, latency_limit_action)>0)) {
|
|
|
+ ms = TICKS_TO_MS(get_ticks_raw());
|
|
|
+ }
|
|
|
+
|
|
|
+ ret = sr_apy_kemi_exec_func_ex(ket, self, args, idx);
|
|
|
+
|
|
|
+ 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))) {
|
|
|
+ pstate = PyThreadState_GET();
|
|
|
+ if (pstate != NULL && pstate->frame != NULL) {
|
|
|
+ pframe = pstate->frame;
|
|
|
+ }
|
|
|
+
|
|
|
+ LOG(cfg_get(core, core_cfg, latency_log),
|
|
|
+ "alert - action KSR.%s%s%s(...)"
|
|
|
+ " took too long [%u ms] (file:%s func:%s line:%d)\n",
|
|
|
+ (ket->mname.len>0)?ket->mname.s:"",
|
|
|
+ (ket->mname.len>0)?".":"", ket->fname.s, ms,
|
|
|
+ (pframe)?PyString_AsString(pframe->f_code->co_filename):"",
|
|
|
+ (pframe)?PyString_AsString(pframe->f_code->co_name):"",
|
|
|
+ (pframe)?PyCode_Addr2Line(pframe->f_code, pframe->f_lasti):0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
*/
|