Module: kamailio
Branch: master
Commit: d8b78bfaab25f9a73a67d813cfa930a6eb754bfa
URL:
https://github.com/kamailio/kamailio/commit/d8b78bfaab25f9a73a67d813cfa930a…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-11-13T09:16:35+01:00
htable: ability to create more than one timer process
---
Modified: modules/htable/ht_api.c
Modified: modules/htable/htable.c
---
Diff:
https://github.com/kamailio/kamailio/commit/d8b78bfaab25f9a73a67d813cfa930a…
Patch:
https://github.com/kamailio/kamailio/commit/d8b78bfaab25f9a73a67d813cfa930a…
---
diff --git a/modules/htable/ht_api.c b/modules/htable/ht_api.c
index 4e272cc..bc20c08 100644
--- a/modules/htable/ht_api.c
+++ b/modules/htable/ht_api.c
@@ -964,6 +964,8 @@ int ht_has_autoexpire(void)
return 0;
}
+extern int ht_timer_procs;
+
void ht_timer(unsigned int ticks, void *param)
{
ht_t *ht;
@@ -971,18 +973,24 @@ void ht_timer(unsigned int ticks, void *param)
ht_cell_t *it0;
time_t now;
int i;
+ int istart;
+ int istep;
if(_ht_root==NULL)
return;
now = time(NULL);
-
+
+ istart = (int)(long)param;
+ if(ht_timer_procs<=0) istep = 1;
+ else istep = ht_timer_procs;
+
ht = _ht_root;
while(ht)
{
if(ht->htexpire>0)
{
- for(i=0; i<ht->htsize; i++)
+ for(i=istart; i<ht->htsize; i+=istep)
{
/* free entries */
ht_slot_lock(ht, i);
diff --git a/modules/htable/htable.c b/modules/htable/htable.c
index 3e803fe..7f55be1 100644
--- a/modules/htable/htable.c
+++ b/modules/htable/htable.c
@@ -212,7 +212,7 @@ static int mod_init(void)
return -1;
}
} else {
- register_sync_timers(1);
+ register_sync_timers(ht_timer_procs);
}
}
@@ -232,15 +232,18 @@ static int child_init(int rank)
struct sip_msg *fmsg;
struct run_act_ctx ctx;
int rtb, rt;
+ int i;
LM_DBG("rank is (%d)\n", rank);
if(rank==PROC_MAIN) {
if(ht_timer_procs>0) {
- if(fork_sync_timer(PROC_TIMER, "HTable Timer", 1 /*socks flag*/,
- ht_timer, NULL, ht_timer_interval)<0) {
- LM_ERR("failed to start timer routine as process\n");
- return -1; /* error */
+ for(i=0; i<ht_timer_procs; i++) {
+ if(fork_sync_timer(PROC_TIMER, "HTable Timer", 1 /*socks flag*/,
+ ht_timer, (void*)(long)i, ht_timer_interval)<0) {
+ LM_ERR("failed to start timer routine as process\n");
+ return -1; /* error */
+ }
}
}
}