Browse Source

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)
Daniel-Constantin Mierla 11 years ago
parent
commit
4c651606eb
1 changed files with 16 additions and 9 deletions
  1. 16 9
      modules/pipelimit/pipelimit.c

+ 16 - 9
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;