- }
- // get first entry from entry list; jump over unused list head
- hash_index = str_hash(key);
- entry = rtpengine_hash_table->entry_list[hash_index];
- last_entry = entry;
- // lock
- lock_get(rtpengine_hash_lock);
- while (entry) {
// if key found, return entry
if (str_equal(&entry->callid, (str *)key)) {
// unlock
lock_release(rtpengine_hash_lock);
return entry;
Returning the raw hash table entries straight from the hash table is dangerous as the entries are protected by the lock and so this opens the door to a race condition. A lookup might return one entry while the same entry is being freed in another process. Either return a copy of the entries or simply return its contents (the node should be enough).
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/390/files#r44553288