<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Please post it to <a href="http://jira.freeswitch.org">jira.freeswitch.org</a><div><br></div><div>/b</div><div><br><div><div>On Nov 28, 2011, at 2:31 AM, Karol Golab wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><br>&nbsp;&nbsp;Hi!<br><br>&nbsp;&nbsp;I've noticed some strange code in src/switch_event.c - could someone<span class="Apple-converted-space">&nbsp;</span><br>smarter (&amp; knowing the mentioned code) please take a look?<br><br>&nbsp;&nbsp;The problem is in the order of calls to locks BLOCK &amp; RWLOCK - it<span class="Apple-converted-space">&nbsp;</span><br>differs between functions:<br><br>switch_event_bind_removable<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch_mutex_lock(BLOCK);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch_thread_rwlock_wrlock(RWLOCK);<br><br>switch_event_unbind_callback<br>&nbsp;&nbsp;&nbsp;&nbsp;switch_thread_rwlock_wrlock(RWLOCK);<br>&nbsp;&nbsp;&nbsp;&nbsp;switch_mutex_lock(BLOCK);<br><br>switch_event_unbind<br>&nbsp;&nbsp;&nbsp;&nbsp;switch_thread_rwlock_wrlock(RWLOCK);<br>&nbsp;&nbsp;&nbsp;&nbsp;switch_mutex_lock(BLOCK);<br><br>&nbsp;&nbsp;As I understand this may lead to an outright deadlock between bind<span class="Apple-converted-space">&nbsp;</span><br>and unbind.<br><br>&nbsp;&nbsp;I stumbled upon this code while debugging what seems like deadlocks<span class="Apple-converted-space">&nbsp;</span><br>in our test FS installation put under some heavy load. The load is about<span class="Apple-converted-space">&nbsp;</span><br>25 new event subscribers per second (destroyed few seconds later) and<span class="Apple-converted-space">&nbsp;</span><br>about 700 events per second.<br><br>&nbsp;&nbsp;Regards,<br>&nbsp;&nbsp;Karol<br></span></blockquote></div><br></div></body></html>