From 997bc78278a8d544e917caaf8672305e56cb7713 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Mon, 23 Nov 2015 12:04:39 +0100 Subject: [PATCH] Revert "rtpengine: Add hash_table_size modparam" This reverts commit a37257d48702c494c080f7f7c86a2dc18957b242. --- modules/rtpengine/doc/rtpengine_admin.xml | 27 +++----------------- modules/rtpengine/rtpengine.c | 14 +++++----- modules/rtpengine/rtpengine_hash.c | 31 ++++++----------------- modules/rtpengine/rtpengine_hash.h | 7 ++--- 4 files changed, 22 insertions(+), 57 deletions(-) diff --git a/modules/rtpengine/doc/rtpengine_admin.xml b/modules/rtpengine/doc/rtpengine_admin.xml index 0c8a6477633..2454db2aa05 100644 --- a/modules/rtpengine/doc/rtpengine_admin.xml +++ b/modules/rtpengine/doc/rtpengine_admin.xml @@ -388,26 +388,8 @@ modparam("rtpproxy", "rtp_inst_pvar", "$avp(RTP_INSTANCE)") -
- <varname>hash_table_size</varname> (integer) - - Size of the hash table. Default value is 256. - - - NOTE: If configured size is less than 1, the size will be defaulted to 1. - - - Set <varname>hash_table_size</varname> parameter - -... -modparam("rtpproxy", "hash_table_size", "123") -... - - -
- -
- <varname>hash_table_tout</varname> (integer) +
+ <varname>hash_entry_tout</varname> (string) Number of seconds after an rtpengine hash table entry is marked for deletion. By default, this parameter is set to 120 (seconds). @@ -423,16 +405,15 @@ modparam("rtpproxy", "hash_table_size", "123") while insert/remove/lookup the hastable, only for the entries in the insert/remove/lookup path. - Set <varname>hash_table_tout</varname> parameter + Set <varname>hash_entry_tout</varname> parameter ... -modparam("rtpproxy", "hash_table_tout", "300") +modparam("rtpproxy", "hash_entry_tout", "300") ...
-
diff --git a/modules/rtpengine/rtpengine.c b/modules/rtpengine/rtpengine.c index e48f31811e1..e1ec46c8dca 100644 --- a/modules/rtpengine/rtpengine.c +++ b/modules/rtpengine/rtpengine.c @@ -231,8 +231,7 @@ static pid_t mypid; static unsigned int myseqn = 0; static str extra_id_pv_param = {NULL, 0}; static char *setid_avp_param = NULL; -static int hash_table_tout = 120; -static int hash_table_size = 256; +static int hash_entry_tout = 120; static char ** rtpp_strings=0; static int rtpp_sets=0; /*used in rtpengine_set_store()*/ @@ -341,8 +340,7 @@ static param_export_t params[] = { {"rtp_inst_pvar", PARAM_STR, &rtp_inst_pv_param }, {"write_sdp_pv", PARAM_STR, &write_sdp_pvar_str }, {"read_sdp_pv", PARAM_STR, &read_sdp_pvar_str }, - {"hash_table_tout", INT_PARAM, &hash_table_tout }, - {"hash_table_size", INT_PARAM, &hash_table_size }, + {"hash_entry_tout", INT_PARAM, &hash_entry_tout }, {0, 0, 0} }; @@ -1448,11 +1446,11 @@ mod_init(void) } /* init the hastable which keeps the call-id <-> selected_node relation */ - if (!rtpengine_hash_table_init(hash_table_size)) { - LM_ERR("rtpengine_hash_table_init(%d) failed!\n", hash_table_size); + if (!rtpengine_hash_table_init()) { + LM_ERR("rtpengine_hash_table_init() failed!\n"); return -1; } else { - LM_DBG("rtpengine_hash_table_init(%d) success!\n", hash_table_size); + LM_DBG("rtpengine_hash_table_init() success!\n"); } return 0; @@ -2309,7 +2307,7 @@ select_rtpp_node_new(str callid, int do_test, int op) } entry->node = node; entry->next = NULL; - entry->tout = get_ticks() + hash_table_tout; + entry->tout = get_ticks() + hash_entry_tout; /* Insert the key<->entry from the hashtable */ if (!rtpengine_hash_table_insert(&callid, entry)) { diff --git a/modules/rtpengine/rtpengine_hash.c b/modules/rtpengine/rtpengine_hash.c index 3cca5749f6e..f23b45db48c 100644 --- a/modules/rtpengine/rtpengine_hash.c +++ b/modules/rtpengine/rtpengine_hash.c @@ -8,7 +8,6 @@ static gen_lock_t *rtpengine_hash_lock; static struct rtpengine_hash_table *rtpengine_hash_table; -static int hash_table_size; /* from sipwise rtpengine */ static int str_cmp_str(const str *a, const str *b) { @@ -38,21 +37,13 @@ static unsigned int str_hash(void *ss) { it.len--; } - return ret % hash_table_size; + return ret % RTPENGINE_HASH_TABLE_SIZE; } /* rtpengine glib hash API */ -int rtpengine_hash_table_init(int size) { +int rtpengine_hash_table_init() { int i; - // init hash table size - if (size < 1) { - hash_table_size = 1; - } else { - hash_table_size = size; - } - LM_DBG("rtpengine_hash_table size = %d\n", hash_table_size); - // init hashtable rtpengine_hash_table = shm_malloc(sizeof(struct rtpengine_hash_table)); if (!rtpengine_hash_table) { @@ -60,18 +51,15 @@ int rtpengine_hash_table_init(int size) { return 0; } - // init hashtable entry_list - rtpengine_hash_table->entry_list = shm_malloc(hash_table_size * sizeof(struct rtpengine_hash_entry)); - - // init hashtable entry_list[i] (head never filled) - for (i = 0; i < hash_table_size; i++) { + // init hashtable entry_list heads (never filled) + for (i = 0; i < RTPENGINE_HASH_TABLE_SIZE; i++) { rtpengine_hash_table->entry_list[i] = shm_malloc(sizeof(struct rtpengine_hash_entry)); if (!rtpengine_hash_table->entry_list[i]) { LM_ERR("no shm left to create rtpengine_hash_table->entry_list[%d]\n", i); return 0; } - // never expire the head of the hashtable index lists + /* never expire the head of the hashtable index lists */ rtpengine_hash_table->entry_list[i]->tout = -1; rtpengine_hash_table->entry_list[i]->next = NULL; } @@ -96,9 +84,9 @@ int rtpengine_hash_table_destroy() { return 0; } - // destroy hashtable entry_list[i] + // destroy hashtable entry_list content lock_get(rtpengine_hash_lock); - for (i = 0; i < hash_table_size; i++) { + for (i = 0; i < RTPENGINE_HASH_TABLE_SIZE; i++) { entry = rtpengine_hash_table->entry_list[i]; while (entry) { last_entry = entry; @@ -108,9 +96,6 @@ int rtpengine_hash_table_destroy() { } } - // destroy hashtable entry_list - shm_free(rtpengine_hash_table->entry_list); - // destroy hashtable shm_free(rtpengine_hash_table); rtpengine_hash_table = NULL; @@ -298,7 +283,7 @@ void rtpengine_hash_table_print() { lock_get(rtpengine_hash_lock); // print hashtable - for (i = 0; i < hash_table_size; i++) { + for (i = 0; i < RTPENGINE_HASH_TABLE_SIZE; i++) { entry = rtpengine_hash_table->entry_list[i]; last_entry = entry; diff --git a/modules/rtpengine/rtpengine_hash.h b/modules/rtpengine/rtpengine_hash.h index b0a8c739317..71a73b45b1e 100644 --- a/modules/rtpengine/rtpengine_hash.h +++ b/modules/rtpengine/rtpengine_hash.h @@ -3,6 +3,7 @@ #include "../../str.h" +#define RTPENGINE_HASH_TABLE_SIZE 512 /* table entry */ struct rtpengine_hash_entry { @@ -10,16 +11,16 @@ struct rtpengine_hash_entry { str callid; // call callid struct rtpp_node *node; // call selected node - struct rtpengine_hash_entry *next; // call next + struct rtpengine_hash_entry *next; // next }; /* table */ struct rtpengine_hash_table { - struct rtpengine_hash_entry **entry_list; + struct rtpengine_hash_entry *entry_list[RTPENGINE_HASH_TABLE_SIZE]; }; -int rtpengine_hash_table_init(int size); +int rtpengine_hash_table_init(); int rtpengine_hash_table_destroy(); int rtpengine_hash_table_insert(void *key, void *value); int rtpengine_hash_table_remove(void *key);