[sr-dev] git:master: pipelimit: added hash_size parameter

Daniel-Constantin Mierla miconda at gmail.com
Tue Apr 29 22:53:32 CEST 2014


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Tue Apr 29 22:43:27 2014 +0200

pipelimit: added hash_size parameter

- can be used to set the number of slots for the internal hash table,
  which is computed as 2^hash_size (aka 1<<hash_size)
- default is 6 (2^6 = 64 slots)

---

 modules/pipelimit/pipelimit.c |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/modules/pipelimit/pipelimit.c b/modules/pipelimit/pipelimit.c
index a2a39b5..0fdd06c 100644
--- a/modules/pipelimit/pipelimit.c
+++ b/modules/pipelimit/pipelimit.c
@@ -78,6 +78,7 @@ str_map_t source_names[] = {
 
 static int pl_drop_code = 503;
 static str pl_drop_reason = str_init("Server Unavailable");
+static int pl_hash_size = 6;
 
 typedef struct pl_queue {
 	int     *       pipe;
@@ -132,14 +133,15 @@ static cmd_export_t cmds[]={
 	{0,0,0,0,0,0}
 };
 static param_export_t params[]={
-	{"timer_interval", INT_PARAM,                &timer_interval},
-	{"reply_code",     INT_PARAM,                &pl_drop_code},
-	{"reply_reason",   STR_PARAM,                &pl_drop_reason.s},
-	{"db_url",            STR_PARAM,             &pl_db_url},
-	{"plp_table_name",    STR_PARAM,             &rlp_table_name},
-	{"plp_pipeid_column",    STR_PARAM,             &rlp_pipeid_col},
-	{"plp_limit_column",     STR_PARAM,             &rlp_limit_col},
-	{"plp_algorithm_column", STR_PARAM,             &rlp_algorithm_col},
+	{"timer_interval",       INT_PARAM,          &timer_interval},
+	{"reply_code",           INT_PARAM,          &pl_drop_code},
+	{"reply_reason",         STR_PARAM,          &pl_drop_reason.s},
+	{"db_url",               STR_PARAM,          &pl_db_url},
+	{"plp_table_name",       STR_PARAM,          &rlp_table_name},
+	{"plp_pipeid_column",    STR_PARAM,          &rlp_pipeid_col},
+	{"plp_limit_column",     STR_PARAM,          &rlp_limit_col},
+	{"plp_algorithm_column", STR_PARAM,          &rlp_algorithm_col},
+	{"hash_size",            INT_PARAM,          &pl_hash_size},
 
 	{0,0,0}
 };
@@ -296,7 +298,12 @@ static int mod_init(void)
 		LM_ERR("failed to register MI commands\n");
 		return -1;
 	}
-	if(pl_init_htable(16)<0)
+	if(pl_hash_size<=0)
+	{
+		LM_ERR("invalid hash size parameter: %d\n", pl_hash_size);
+		return -1;
+	}
+	if(pl_init_htable(1<<pl_hash_size)<0)
 	{
 		LM_ERR("could not allocate pipes htable\n");
 		return -1;




More information about the sr-dev mailing list