From b6e2dce80a607b12276addea310c9696c3c39ce9 Mon Sep 17 00:00:00 2001 From: Stefan Mititelu Date: Wed, 27 Jan 2016 10:50:22 +0200 Subject: [PATCH] rtpengine: Init and dealloc hastable locks Right now only alloc and destroy is done. Also do init and dealloc. --- modules/rtpengine/rtpengine_hash.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/rtpengine/rtpengine_hash.c b/modules/rtpengine/rtpengine_hash.c index f8e610d82d9..b36e93e3030 100644 --- a/modules/rtpengine/rtpengine_hash.c +++ b/modules/rtpengine/rtpengine_hash.c @@ -92,7 +92,7 @@ int rtpengine_hash_table_init(int size) { // init hashtable row_locks[i], row_entry_list[i] and row_totals[i] for (i = 0; i < hash_table_size; i++) { - // init hashtable row_locks[i] + // alloc hashtable row_locks[i] rtpengine_hash_table->row_locks[i] = lock_alloc(); if (!rtpengine_hash_table->row_locks[i]) { LM_ERR("no shm left to create rtpengine_hash_table->row_locks[%d]\n", i); @@ -100,6 +100,13 @@ int rtpengine_hash_table_init(int size) { return 0; } + // init hashtable row_locks[i] + if (!lock_init(rtpengine_hash_table->row_locks[i])) { + LM_ERR("fail to init rtpengine_hash_table->row_locks[%d]\n", i); + rtpengine_hash_table_destroy(); + return 0; + } + // init hashtable row_entry_list[i] rtpengine_hash_table->row_entry_list[i] = shm_malloc(sizeof(struct rtpengine_hash_entry)); if (!rtpengine_hash_table->row_entry_list[i]) { @@ -511,6 +518,7 @@ static void rtpengine_hash_table_free_row_lock(gen_lock_t *row_lock) { } lock_destroy(row_lock); + lock_dealloc(row_lock); return ; }