[sr-dev] [kamailio] rtpengine: hash table to keep the selected nodes (#390)

Richard Fuchs notifications at github.com
Wed Nov 11 17:37:07 CET 2015


> +	}
> +
> +	// 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20151111/9ae01e34/attachment.html>


More information about the sr-dev mailing list