From 4fb0dc4a6fb13a2cedacfe20fb80641a9a8915b3 Mon Sep 17 00:00:00 2001 From: Alex Hermann Date: Thu, 13 Nov 2014 16:15:06 +0100 Subject: [PATCH] rtimer: Allow multiple timer processes per timer Reuse the mode parameter to specify the number of processes handling the timer. --- modules/rtimer/README | 4 +++- modules/rtimer/doc/rtimer_admin.xml | 5 +++-- modules/rtimer/rtimer_mod.c | 17 ++++++++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/modules/rtimer/README b/modules/rtimer/README index cafd917de15..98dd0cda52a 100644 --- a/modules/rtimer/README +++ b/modules/rtimer/README @@ -87,7 +87,9 @@ Chapter 1. Admin Guide The parameter can be set multiple times to get more timers in same configuration file. * name - name of the timer. - * mode - if set to 1, will create a new timer process. + * mode - if set to 0, the timer will use the main (shared) timer. Any + number > 0 will create the specified amount of new timer processes + (which will only be handling this timer). * interval - timer interval in seconds or micro-seconds (the value must be ended in 'u'). For micro-seconds intervals, mode is set always to 1. diff --git a/modules/rtimer/doc/rtimer_admin.xml b/modules/rtimer/doc/rtimer_admin.xml index 73ee0e483aa..7b099ef0467 100644 --- a/modules/rtimer/doc/rtimer_admin.xml +++ b/modules/rtimer/doc/rtimer_admin.xml @@ -81,8 +81,9 @@ - mode - if set to 1, will create a new timer - process. + mode - if set to 0, the timer will use the main + (shared) timer. Any number > 0 will create the specified amount of + new timer processes (which will only be handling this timer). diff --git a/modules/rtimer/rtimer_mod.c b/modules/rtimer/rtimer_mod.c index a15a08c23df..3a1e56a2375 100644 --- a/modules/rtimer/rtimer_mod.c +++ b/modules/rtimer/rtimer_mod.c @@ -127,7 +127,7 @@ static int mod_init(void) return -1; } } else { - register_basic_timers(1); + register_basic_timers(it->mode); } it = it->next; } @@ -138,6 +138,9 @@ static int mod_init(void) static int child_init(int rank) { stm_timer_t *it; + int i; + char si_desc[MAX_PT_DESC]; + if(_stm_list==NULL) return 0; @@ -147,18 +150,20 @@ static int child_init(int rank) it = _stm_list; while(it) { - if(it->mode!=0) + for(i=0; imode; i++) { + snprintf(si_desc, MAX_PT_DESC, "RTIMER EXEC child=%d timer=%.*s", + i, it->name.len, it->name.s); if(it->flags & RTIMER_INTERVAL_USEC) { - if(fork_basic_utimer(PROC_TIMER, "RTIMER USEC EXEC", 1 /*socks flag*/, + if(fork_basic_utimer(PROC_TIMER, si_desc, 1 /*socks flag*/, stm_timer_exec, (void*)it, it->interval /*usec*/)<0) { LM_ERR("failed to start utimer routine as process\n"); return -1; /* error */ } } else { - if(fork_basic_timer(PROC_TIMER, "RTIMER SEC EXEC", 1 /*socks flag*/, + if(fork_basic_timer(PROC_TIMER, si_desc, 1 /*socks flag*/, stm_timer_exec, (void*)it, it->interval /*sec*/)<0) { LM_ERR("failed to start timer routine as process\n"); @@ -236,7 +241,9 @@ int stm_t_param(modparam_t type, void *val) || pit->body.s[pit->body.len-1]=='U') { pit->body.len--; tmp.flags |= RTIMER_INTERVAL_USEC; - tmp.mode = 1; + if (tmp.mode==0) { + tmp.mode = 1; + } } if (str2int(&pit->body, &tmp.interval) < 0) { LM_ERR("invalid interval: %.*s\n", pit->body.len, pit->body.s);