Selaa lähdekoodia

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
Stefan Mititelu 9 vuotta sitten
vanhempi
commit
a4c5af2df6
1 muutettua tiedostoa jossa 13 lisäystä ja 4 poistoa
  1. 13 4
      modules/rtpengine/rtpengine_hash.c

+ 13 - 4
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 callid found, delete entry
 		if ((str_equal(entry->callid, callid) && str_equal(entry->viabranch, viabranch)) ||
 		if ((str_equal(entry->callid, callid) && str_equal(entry->viabranch, viabranch)) ||
 		    (str_equal(entry->callid, callid) && viabranch.len == 0 && op == OP_DELETE)) {
 		    (str_equal(entry->callid, callid) && viabranch.len == 0 && op == OP_DELETE)) {
-			// free entry
+			// set pointers; exclude entry
 			last_entry->next = entry->next;
 			last_entry->next = entry->next;
+
+			// free current entry; entry points to unknown
 			rtpengine_hash_table_free_entry(entry);
 			rtpengine_hash_table_free_entry(entry);
 
 
+			// set pointers
+			entry = last_entry;
+
 			// update total
 			// update total
 			rtpengine_hash_table->row_totals[hash_index]--;
 			rtpengine_hash_table->row_totals[hash_index]--;
 
 
-			// unlock
-			lock_release(rtpengine_hash_table->row_locks[hash_index]);
-
 			found = 1;
 			found = 1;
 
 
 			if (!(viabranch.len == 0 && op == OP_DELETE)) {
 			if (!(viabranch.len == 0 && op == OP_DELETE)) {
+				// unlock
+				lock_release(rtpengine_hash_table->row_locks[hash_index]);
 				return found;
 				return found;
 			}
 			}
+
+			// try to also delete other viabranch entries for callid
+			last_entry = entry;
+			entry = entry->next;
+			continue;
 		}
 		}
 
 
 		// if expired entry discovered, delete it
 		// if expired entry discovered, delete it