[sr-dev] git:master: dialog: option to run dialog main timer tasks via dedicated process

Daniel-Constantin Mierla miconda at gmail.com
Wed Jul 30 15:27:35 CEST 2014


Module: sip-router
Branch: master
Commit: 1157db7c72b1629b72f4d06bd01c5bc694a816b2
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=1157db7c72b1629b72f4d06bd01c5bc694a816b2

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Wed Jul 30 15:15:40 2014 +0200

dialog: option to run dialog main timer tasks via dedicated process

- timer_procs - new parameter, if set to 1, a dedicated timer process is
  used, if set to 0 (default), the core timer is used (existing
  behavior)
- to add: option to work with many dedicated timer processes

---

 modules/dialog/dialog.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/modules/dialog/dialog.c b/modules/dialog/dialog.c
index 4495625..1baa714 100644
--- a/modules/dialog/dialog.c
+++ b/modules/dialog/dialog.c
@@ -109,6 +109,7 @@ str dlg_extra_hdrs = {NULL,0};
 static int db_fetch_rows = 200;
 int initial_cbs_inscript = 1;
 int dlg_wait_ack = 1;
+static int dlg_timer_procs = 0;
 
 int dlg_event_rt[DLG_EVENTRT_MAX];
 
@@ -285,6 +286,7 @@ static param_export_t mod_params[]={
 	{ "ka_timer",              INT_PARAM, &dlg_ka_timer             },
 	{ "ka_interval",           INT_PARAM, &dlg_ka_interval          },
 	{ "timeout_noreset",       INT_PARAM, &dlg_timeout_noreset      },
+	{ "timer_procs",           PARAM_INT, &dlg_timer_procs          },
 	{ 0,0,0 }
 };
 
@@ -614,9 +616,13 @@ static int mod_init(void)
 		return -1;
 	}
 
-	if ( register_timer( dlg_timer_routine, 0, 1)<0 ) {
-		LM_ERR("failed to register timer \n");
-		return -1;
+	if(dlg_timer_procs<=0) {
+		if ( register_timer( dlg_timer_routine, 0, 1)<0 ) {
+			LM_ERR("failed to register timer \n");
+			return -1;
+		}
+	} else {
+		register_sync_timers(1);
 	}
 
 	/* init handlers */
@@ -692,6 +698,14 @@ static int child_init(int rank)
 	dlg_db_mode = dlg_db_mode_param;
 
 	if(rank==PROC_MAIN) {
+		if(dlg_timer_procs>0) {
+			if(fork_sync_timer(PROC_TIMER, "Dialog Main Timer", 1 /*socks flag*/,
+					dlg_timer_routine, NULL, 1 /*every sec*/)<0) {
+				LM_ERR("failed to start main timer routine as process\n");
+				return -1; /* error */
+			}
+		}
+
 		if(dlg_ka_timer>0 && dlg_ka_interval>0) {
 			if(fork_sync_timer(PROC_TIMER, "Dialog KA Timer", 1 /*socks flag*/,
 					dlg_ka_timer_exec, NULL, dlg_ka_timer /*sec*/)<0) {




More information about the sr-dev mailing list