<p></p>
<p dir="auto">It is expected to be slower for larger number of items in the queue. There can be some improvements by keeping a hash table with the names of the items in the key to speed up the search, but that will also add to complexity.</p>
<p dir="auto">From my point of view, this would be a specific use case where one has to be aware of consequences to processing speed. But if it useful in some cases, then that's how it is.</p>
<p dir="auto">In other words, I am still fine to merge it, but I think there has to be no unlock (lock release) after the if with the mode:</p>
<ul dir="auto">
<li><a class="commit-link" href="https://github.com/kamailio/kamailio/commit/8a3587004c27f1dc2aaa078c6508f5606124ccba#diff-32730fc08fc59be73bbefa3ec2551f08013719505f9f057d865e4c688a896a79R342"><tt>8a35870</tt>#diff-32730fc08fc59be73bbefa3ec2551f08013719505f9f057d865e4c688a896a79R342</a></li>
</ul>
<p dir="auto">And the next lock_get() has to be removed. Practically, everything has to be done in a single lock_get() ... lock_release(), otherwise there is a short time frame open for races: the if block does not find the item with the name, does lock release, loses CPU for a while, and during that time another process adds an item with the same name.</p>
<p dir="auto">The penalty is that the shm alloc and copy for the new item is done inside the lock. But probably a condition on <code>mh->addmode</code> can be leveraged to do the lock/unlock at the better place, because <code>mh->addmode</code> is set at startup and never changes, plus that <code>mh</code> does not get destroyed during runtime.</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/pull/3053#issuecomment-1077625284">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZMM3WEZGTYED23BCKDVBRUMZANCNFSM5QUW7QNQ">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/ABO7UZL3MFRUTX6VAJQWX7TVBRUMZA5CNFSM5QUW7QN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIA5UDRA.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><kamailio/kamailio/pull/3053/c1077625284</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/pull/3053#issuecomment-1077625284",
"url": "https://github.com/kamailio/kamailio/pull/3053#issuecomment-1077625284",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>