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

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2021-04-08T11:54:33+02:00

rtpengine: reworked condition around locking for easier pairing

- inside rtpengine_hash_table_insert()

---

Modified: src/modules/rtpengine/rtpengine_hash.c

---

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

---

diff --git a/src/modules/rtpengine/rtpengine_hash.c 
b/src/modules/rtpengine/rtpengine_hash.c
index eda947fe26..770bf494e0 100644
--- a/src/modules/rtpengine/rtpengine_hash.c
+++ b/src/modules/rtpengine/rtpengine_hash.c
@@ -221,16 +221,16 @@ int rtpengine_hash_table_insert(str callid, str 
viabranch, struct rtpengine_hash
        // get entry list
        hash_index = str_hash(callid);
        entry = rtpengine_hash_table->row_entry_list[hash_index];
-       last_entry = entry;
 
-       // lock
-       if (rtpengine_hash_table->row_locks[hash_index]) {
-               lock_get(rtpengine_hash_table->row_locks[hash_index]);
-       } else {
-               LM_ERR("NULL rtpengine_hash_table->row_locks[%d]\n", 
hash_index);
+       if (entry==NULL || rtpengine_hash_table->row_locks[hash_index]==NULL) {
+               LM_ERR("NULL entry or lock for hash table slot[%d]\n", 
hash_index);
                return 0;
        }
 
+       last_entry = entry;
+       // lock
+       lock_get(rtpengine_hash_table->row_locks[hash_index]);
+
        while (entry) {
                // if found, don't add new entry
                if (str_equal(entry->callid, new_entry->callid) &&


_______________________________________________
Kamailio (SER) - Development Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to