[sr-dev] git:master:4368987b: rtimer: add one new module parameter

Daniel-Constantin Mierla miconda at gmail.com
Sat Aug 28 20:17:34 CEST 2021


Module: kamailio
Branch: master
Commit: 4368987be5b17faf443104e6193a559492625fe6
URL: https://github.com/kamailio/kamailio/commit/4368987be5b17faf443104e6193a559492625fe6

Author: Stefan Mititelu <stefan-cristian.mititelu at 1and1.ro>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-08-28T20:17:30+02:00

rtimer: add one new module parameter

Add default_interval to set the fire interval,
if interval not present inside timer string.

---

Modified: src/modules/rtimer/doc/rtimer_admin.xml
Modified: src/modules/rtimer/rtimer_mod.c

---

Diff:  https://github.com/kamailio/kamailio/commit/4368987be5b17faf443104e6193a559492625fe6.diff
Patch: https://github.com/kamailio/kamailio/commit/4368987be5b17faf443104e6193a559492625fe6.patch

---

diff --git a/src/modules/rtimer/doc/rtimer_admin.xml b/src/modules/rtimer/doc/rtimer_admin.xml
index 92422c5f3e..676bf2f5ad 100644
--- a/src/modules/rtimer/doc/rtimer_admin.xml
+++ b/src/modules/rtimer/doc/rtimer_admin.xml
@@ -56,6 +56,25 @@
 	</section>
 	<section>
 	<title>Parameters</title>
+	<section>
+		<title><varname>default_interval</varname> (int)</title>
+		<para>
+			The definition of the default interval of timers (if not present on the "timer" parameter)
+		</para>
+		<para>
+			The parameter can be set multiple times to get different intervals in same configuration file.
+		</para>
+		<example>
+		<title>Set <varname>default_interval</varname> parameter</title>
+		<programlisting format="linespecific">
+...
+# default time interval set to 300 seconds
+modparam("rtimer", "default_interval", 300)
+...
+		</programlisting>
+		</example>
+	</section>
+
 	<section>
 		<title><varname>timer</varname> (str)</title>
 		<para>
diff --git a/src/modules/rtimer/rtimer_mod.c b/src/modules/rtimer/rtimer_mod.c
index 4b398148ee..8111dfac5d 100644
--- a/src/modules/rtimer/rtimer_mod.c
+++ b/src/modules/rtimer/rtimer_mod.c
@@ -78,12 +78,15 @@ void stm_timer_exec(unsigned int ticks, int worker, void *param);
 void stm_main_timer_exec(unsigned int ticks, void *param);
 int stm_get_worker(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
 
+static int default_interval = 120;
+
 static pv_export_t rtimer_pvs[] = {
 	{{"rtimer_worker", (sizeof("rtimer_worker")-1)}, PVT_OTHER, stm_get_worker, 0,	0, 0, 0, 0},
 	{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
 };
 
 static param_export_t params[]={
+	{"default_interval",       INT_PARAM, &default_interval},
 	{"timer",             PARAM_STRING|USE_FUNC_PARAM, (void*)stm_t_param},
 	{"exec",              PARAM_STRING|USE_FUNC_PARAM, (void*)stm_e_param},
 	{0,0,0}
@@ -294,7 +297,7 @@ int stm_t_param(modparam_t type, void *val)
 		return -1;
 	}
 	if(tmp.interval==0)
-		tmp.interval = 120;
+		tmp.interval = default_interval;
 
 	nt = (stm_timer_t*)pkg_malloc(sizeof(stm_timer_t));
 	if(nt==0)
@@ -307,6 +310,7 @@ int stm_t_param(modparam_t type, void *val)
 	nt->next = _stm_list;
 	_stm_list = nt;
 	free_params(params_list);
+	LM_INFO("created rtimer name=%.*s interval=%d mode=%d\n", tmp.name.len, tmp.name.s, tmp.interval, tmp.mode);
 	return 0;
 }
 




More information about the sr-dev mailing list