Module: kamailio
Branch: master
Commit: a4c5af2df65a2711ea7f0fd97e7d9b8e65461a4b
URL: 
https://github.com/kamailio/kamailio/commit/a4c5af2df65a2711ea7f0fd97e7d9b8e65461a4b

Author: Stefan Mititelu <stefan.mitit...@1and1.ro>
Committer: Stefan Mititelu <stefan.mitit...@1and1.ro>
Date: 2016-02-23T10:08:56+02:00

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

---

Modified: modules/rtpengine/rtpengine_hash.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/a4c5af2df65a2711ea7f0fd97e7d9b8e65461a4b.diff
Patch: 
https://github.com/kamailio/kamailio/commit/a4c5af2df65a2711ea7f0fd97e7d9b8e65461a4b.patch

---

diff --git a/modules/rtpengine/rtpengine_hash.c 
b/modules/rtpengine/rtpengine_hash.c
index 66f1cb1..5821fe8 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


_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to