[Freeswitch-dev] Possible deadlock in src/switch_event.c ?

Karol Golab karol at tls.pl
Mon Nov 28 23:33:02 MSK 2011


   Thanks!

   The idea of using EventConsumer per connection seemed pretty natural 
for me - thus my surprise at your warning as I'd expect that it's a 
standard way to use events. Well, it shows I'm a newbie to FS ;)

   Regards,
   Karol


On 11/28/2011 09:26 PM, Anthony Minessale wrote:
> you can do whatever you wish.  I was just warning you that nobody has 
> really pushed event binding and unbinding in such a way before which 
> may explain how you uncovered that issue.  Usually things that bind 
> stay resident for a long time.
>
>
> 2011/11/28 Karol Golab <karol at tls.pl <mailto:karol at tls.pl>>
>
>
>       Well, I have a Perl script run as part of a dialplan and the
>     script creates an EventConsumer. Thus I have one bind / unbind
>     pair for each connection. Is this somehow wrong / against what the
>     EventConsumer API was planned for?
>       How could I have a single bind/unbind in this case?
>
>       As for choosing event socket and C application vs a script -
>     what is the main difference / reason to switch: performance of
>     some other issues? My CPU seems to have some cycles to spare.
>
>       Regards,
>       Karol
>
>
>
>     On 11/28/2011 05:36 PM, Anthony Minessale wrote:
>>     you're probably right but I wonder what you are doing that is
>>     binding and unbinding so much?
>>     The bind and unbind was designed to be called once when the
>>     module is loaded and called again when it exits.
>>
>>     My fear is you are using the embedded scripting event handers in
>>     some quick repeating fashion.
>>
>>     I did a commit to flip that case around but I don't encourage you
>>     to use embedded scripts for heavy event traffic, that's what
>>     event socket is for and if you have the C skills to debug this,
>>     you might want to try a C app ;)
>>
>>
>>     2011/11/28 Brian West <brian at freeswitch.org
>>     <mailto:brian at freeswitch.org>>
>>
>>         Please post it to jira.freeswitch.org
>>         <http://jira.freeswitch.org>
>>
>>         /b
>>
>>         On Nov 28, 2011, at 2:31 AM, Karol Golab wrote:
>>
>>>
>>>           Hi!
>>>
>>>           I've noticed some strange code in src/switch_event.c -
>>>         could someone
>>>         smarter (& knowing the mentioned code) please take a look?
>>>
>>>           The problem is in the order of calls to locks BLOCK &
>>>         RWLOCK - it
>>>         differs between functions:
>>>
>>>         switch_event_bind_removable
>>>                 switch_mutex_lock(BLOCK);
>>>                 switch_thread_rwlock_wrlock(RWLOCK);
>>>
>>>         switch_event_unbind_callback
>>>             switch_thread_rwlock_wrlock(RWLOCK);
>>>             switch_mutex_lock(BLOCK);
>>>
>>>         switch_event_unbind
>>>             switch_thread_rwlock_wrlock(RWLOCK);
>>>             switch_mutex_lock(BLOCK);
>>>
>>>           As I understand this may lead to an outright deadlock
>>>         between bind
>>>         and unbind.
>>>
>>>           I stumbled upon this code while debugging what seems like
>>>         deadlocks
>>>         in our test FS installation put under some heavy load. The
>>>         load is about
>>>         25 new event subscribers per second (destroyed few seconds
>>>         later) and
>>>         about 700 events per second.
>>>
>>>           Regards,
>>>           Karol
>>
>>
>>         _________________________________________________________________________
>>         Professional FreeSWITCH Consulting Services:
>>         consulting at freeswitch.org <mailto:consulting at freeswitch.org>
>>         http://www.freeswitchsolutions.com
>>
>>         
>>         
>>
>>         Official FreeSWITCH Sites
>>         http://www.freeswitch.org
>>         http://wiki.freeswitch.org
>>         http://www.cluecon.com
>>
>>         FreeSWITCH-dev mailing list
>>         FreeSWITCH-dev at lists.freeswitch.org
>>         <mailto:FreeSWITCH-dev at lists.freeswitch.org>
>>         http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
>>         UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
>>         http://www.freeswitch.org
>>
>>
>>
>>
>>     -- 
>>     Anthony Minessale II
>>
>>     FreeSWITCH http://www.freeswitch.org/
>>     ClueCon http://www.cluecon.com/
>>     Twitter: http://twitter.com/FreeSWITCH_wire
>>
>>     AIM: anthm
>>     MSN:anthony_minessale at hotmail.com
>>     <mailto:MSN%3Aanthony_minessale at hotmail.com>
>>     GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com
>>     <mailto:PAYPAL%3Aanthony.minessale at gmail.com>
>>     IRC: irc.freenode.net <http://irc.freenode.net> #freeswitch
>>
>>     FreeSWITCH Developer Conference
>>     sip:888 at conference.freeswitch.org
>>     <mailto:sip%3A888 at conference.freeswitch.org>
>>     googletalk:conf+888 at conference.freeswitch.org
>>     <mailto:googletalk%3Aconf%2B888 at conference.freeswitch.org>
>>     pstn:+19193869900 <tel:%2B19193869900>
>>
>>
>>     _________________________________________________________________________
>>     Professional FreeSWITCH Consulting Services:
>>     consulting at freeswitch.org  <mailto:consulting at freeswitch.org>
>>     http://www.freeswitchsolutions.com
>>
>>     
>>     
>>
>>     Official FreeSWITCH Sites
>>     http://www.freeswitch.org
>>     http://wiki.freeswitch.org
>>     http://www.cluecon.com
>>
>>     FreeSWITCH-dev mailing list
>>     FreeSWITCH-dev at lists.freeswitch.org  <mailto:FreeSWITCH-dev at lists.freeswitch.org>
>>     http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
>>     UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
>>     http://www.freeswitch.org
>
>
>        Karol
>
>     -- 
>         e-mail:Karol.Golab at tls.pl  <mailto:Karol.Golab at tls.pl>
>            www:http://www.tls.pl
>     signature: not found
>
>        company: TLS-Technologie Spółka z ograniczoną odpowiedzialnością z siedzibą w Warszawie przy ul. Polnej 50 00-644; KRS 0000073337 (XII Wydział Gospodarczy KRS); NIP 526-25-78-091; VAT ID PL5262578091; REGON 017349442; kap. zak. 50000,00 zł
>
>
>
>     _________________________________________________________________________
>     Professional FreeSWITCH Consulting Services:
>     consulting at freeswitch.org <mailto:consulting at freeswitch.org>
>     http://www.freeswitchsolutions.com
>
>     
>     
>
>     Official FreeSWITCH Sites
>     http://www.freeswitch.org
>     http://wiki.freeswitch.org
>     http://www.cluecon.com
>
>     FreeSWITCH-dev mailing list
>     FreeSWITCH-dev at lists.freeswitch.org
>     <mailto:FreeSWITCH-dev at lists.freeswitch.org>
>     http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
>     UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
>     http://www.freeswitch.org
>
>
>
>
> -- 
> Anthony Minessale II
>
> FreeSWITCH http://www.freeswitch.org/
> ClueCon http://www.cluecon.com/
> Twitter: http://twitter.com/FreeSWITCH_wire
>
> AIM: anthm
> MSN:anthony_minessale at hotmail.com 
> <mailto:MSN%3Aanthony_minessale at hotmail.com>
> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com 
> <mailto:PAYPAL%3Aanthony.minessale at gmail.com>
> IRC: irc.freenode.net <http://irc.freenode.net> #freeswitch
>
> FreeSWITCH Developer Conference
> sip:888 at conference.freeswitch.org 
> <mailto:sip%3A888 at conference.freeswitch.org>
> googletalk:conf+888 at conference.freeswitch.org 
> <mailto:googletalk%3Aconf%2B888 at conference.freeswitch.org>
> pstn:+19193869900
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> 
> 
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-dev mailing list
> FreeSWITCH-dev at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
> http://www.freeswitch.org


   Karol

-- 
    e-mail: Karol.Golab at tls.pl
       www: http://www.tls.pl
signature: not found

   company: TLS-Technologie Spółka z ograniczoną odpowiedzialnością z siedzibą w Warszawie przy ul. Polnej 50 00-644; KRS 0000073337 (XII Wydział Gospodarczy KRS); NIP 526-25-78-091; VAT ID PL5262578091; REGON 017349442; kap. zak. 50000,00 zł


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20111128/597b0623/attachment-0001.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-dev mailing list