Module: kamailio
Branch: master
Commit: a2b089939afc5309fc86d68bc9d43619bda4fec5
URL:
https://github.com/kamailio/kamailio/commit/a2b089939afc5309fc86d68bc9d4361…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-02-16T09:39:43+01:00
async: added variable $async(key)
- get async task group name and async task data
---
Modified: src/modules/async/async_mod.c
Modified: src/modules/async/async_sleep.c
Modified: src/modules/async/async_sleep.h
---
Diff:
https://github.com/kamailio/kamailio/commit/a2b089939afc5309fc86d68bc9d4361…
Patch:
https://github.com/kamailio/kamailio/commit/a2b089939afc5309fc86d68bc9d4361…
---
diff --git a/src/modules/async/async_mod.c b/src/modules/async/async_mod.c
index 1020cd0c46..69717273b9 100644
--- a/src/modules/async/async_mod.c
+++ b/src/modules/async/async_mod.c
@@ -92,6 +92,12 @@ static param_export_t params[]={
{0, 0, 0}
};
+static pv_export_t mod_pvs[] = {
+ { {"async", sizeof("async")-1}, PVT_OTHER, pv_get_async, 0,
+ pv_parse_async_name, 0, 0, 0 },
+ { {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
+};
+
struct module_exports exports = {
"async",
DEFAULT_DLFLAGS, /* dlopen flags */
diff --git a/src/modules/async/async_sleep.c b/src/modules/async/async_sleep.c
index 7c46174284..cfbfe98cef 100644
--- a/src/modules/async/async_sleep.c
+++ b/src/modules/async/async_sleep.c
@@ -619,3 +619,59 @@ int async_send_data(sip_msg_t *msg, cfg_action_t *act, str *cbname,
str *gname,
return 0;
}
+
+
+/**
+ *
+ */
+int pv_get_async(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
+{
+ async_wgroup_t *awg = NULL;
+
+ switch(param->pvn.u.isname.name.n) {
+ case 0:
+ if(_ksr_async_data_param==NULL || _ksr_async_data_param->sval.s==NULL
+ || _ksr_async_data_param->sval.len<0) {
+ return pv_get_null(msg, param, res);
+ }
+ return pv_get_strval(msg, param, res, &_ksr_async_data_param->sval);
+ case 1:
+ awg = async_task_workers_get_crt();
+ if(awg==NULL || awg->name.s==NULL || awg->name.len<0) {
+ return pv_get_null(msg, param, res);
+ }
+ return pv_get_strval(msg, param, res, &awg->name);
+ default:
+ return pv_get_null(msg, param, res);
+ }
+}
+
+/**
+ *
+ */
+int pv_parse_geoip_name(pv_spec_t *sp, str *in)
+{
+ if(sp==NULL || in==NULL || in->len<=0)
+ return -1;
+
+ switch(in->len) {
+ case 4:
+ if(strncmp(in->s, "data", 4)==0)
+ sp->pvp.pvn.u.isname.name.n = 0;
+ break;
+ case 5:
+ if(strncmp(in->s, "gname", 5)==0)
+ sp->pvp.pvn.u.isname.name.n = 1;
+ break;
+ default:
+ goto error;
+ }
+ sp->pvp.pvn.type = PV_NAME_INTSTR;
+ sp->pvp.pvn.u.isname.type = 0;
+
+ return 0;
+
+error:
+ LM_ERR("unknown PV time name %.*s\n", in->len, in->s);
+ return -1;
+}
diff --git a/src/modules/async/async_sleep.h b/src/modules/async/async_sleep.h
index 2da46556f2..bb7dd042ce 100644
--- a/src/modules/async/async_sleep.h
+++ b/src/modules/async/async_sleep.h
@@ -53,4 +53,7 @@ int async_send_task(sip_msg_t *msg, cfg_action_t *act, str *cbname, str
*gname);
int async_send_data(sip_msg_t *msg, cfg_action_t *act, str *cbname, str *gname,
str *sdata);
+int pv_get_async(sip_msg_t *msg, pv_param_t *param, pv_value_t *res);
+int pv_parse_async_name(pv_spec_t *sp, str *in);
+
#endif