From a4c5af2df65a2711ea7f0fd97e7d9b8e65461a4b Mon Sep 17 00:00:00 2001 From: Stefan Mititelu Date: Wed, 10 Feb 2016 11:36:45 +0200 Subject: [PATCH] rtpengine: Delete all entries if viabranch.len==0 - try to delete all (callid, viabranchX/Y..) hashtable entries when rtpengine_delete() is called with viabranch.len==0 - release lock before returning --- modules/rtpengine/rtpengine_hash.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/rtpengine/rtpengine_hash.c b/modules/rtpengine/rtpengine_hash.c index 66f1cb177a1..5821fe8c705 100644 --- a/modules/rtpengine/rtpengine_hash.c +++ b/modules/rtpengine/rtpengine_hash.c @@ -302,21 +302,30 @@ int rtpengine_hash_table_remove(str callid, str viabranch, enum rtpe_operation o // if callid found, delete entry if ((str_equal(entry->callid, callid) && str_equal(entry->viabranch, viabranch)) || (str_equal(entry->callid, callid) && viabranch.len == 0 && op == OP_DELETE)) { - // free entry + // set pointers; exclude entry last_entry->next = entry->next; + + // free current entry; entry points to unknown rtpengine_hash_table_free_entry(entry); + // set pointers + entry = last_entry; + // update total rtpengine_hash_table->row_totals[hash_index]--; - // unlock - lock_release(rtpengine_hash_table->row_locks[hash_index]); - found = 1; if (!(viabranch.len == 0 && op == OP_DELETE)) { + // unlock + lock_release(rtpengine_hash_table->row_locks[hash_index]); return found; } + + // try to also delete other viabranch entries for callid + last_entry = entry; + entry = entry->next; + continue; } // if expired entry discovered, delete it