Module: kamailio
Branch: master
Commit: 8e2c2cbf673cd18c0bd90888a75d50903d1c9984
URL:
https://github.com/kamailio/kamailio/commit/8e2c2cbf673cd18c0bd90888a75d509…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-07-21T14:11:37+02:00
cfgutils: sleep() and usleep() accept vars as parameter
---
Modified: modules/cfgutils/cfgutils.c
---
Diff:
https://github.com/kamailio/kamailio/commit/8e2c2cbf673cd18c0bd90888a75d509…
Patch:
https://github.com/kamailio/kamailio/commit/8e2c2cbf673cd18c0bd90888a75d509…
---
diff --git a/modules/cfgutils/cfgutils.c b/modules/cfgutils/cfgutils.c
index c658892..262b21f 100644
--- a/modules/cfgutils/cfgutils.c
+++ b/modules/cfgutils/cfgutils.c
@@ -157,9 +157,9 @@ static cmd_export_t cmds[]={
ANY_ROUTE},
{"rand_event", (cmd_function)rand_event, 0, 0, 0,
ANY_ROUTE},
- {"sleep", (cmd_function)m_sleep, 1, fixup_uint_null, 0,
+ {"sleep", (cmd_function)m_sleep, 1, fixup_igp_null, 0,
ANY_ROUTE},
- {"usleep", (cmd_function)m_usleep, 1, fixup_uint_null, 0,
+ {"usleep", (cmd_function)m_usleep, 1, fixup_igp_null, 0,
ANY_ROUTE},
{"abort", (cmd_function)dbg_abort, 0, 0, 0,
ANY_ROUTE},
@@ -766,15 +766,27 @@ static int pv_get_random_val(struct sip_msg *msg, pv_param_t
*param,
static int m_sleep(struct sip_msg *msg, char *time, char *str2)
{
- LM_DBG("sleep %lu seconds\n", (unsigned long)time);
- sleep((unsigned int)(unsigned long)time);
+ int s;
+ if(fixup_get_ivalue(msg, (gparam_t*)time, &s)!=0)
+ {
+ LM_ERR("cannot get time interval value\n");
+ return -1;
+ }
+ LM_DBG("sleep %lu seconds\n", (unsigned long)s);
+ sleep((unsigned int)s);
return 1;
}
static int m_usleep(struct sip_msg *msg, char *time, char *str2)
{
+ int s;
+ if(fixup_get_ivalue(msg, (gparam_t*)time, &s)!=0)
+ {
+ LM_ERR("cannot get time interval value\n");
+ return -1;
+ }
LM_DBG("sleep %lu microseconds\n", (unsigned long)time);
- sleep_us((unsigned int)(unsigned long)time);
+ sleep_us((unsigned int)s);
return 1;
}