[asterisk-dev] [Code Review]: BLF Subscriptions Causes SIP Deadlock

opticron reviewboard at asterisk.org
Fri Nov 4 13:01:03 CDT 2011



> On Nov. 4, 2011, 12:03 p.m., David Vossel wrote:
> > trunk/channels/chan_sip.c, lines 14395-14400
> > <https://reviewboard.asterisk.org/r/1563/diff/2/?file=21625#file21625line14395>
> >
> >     The ref counts here should be removed. If we don't already own a ref before entering this function, grabbing one now doesn't help anything.
> >     
> >     I've looked at this callback in quite a bit of detail. Because of the way the event is removed during the "clear_peer_mailboxes(peer)" function in the peer's destructor, we are guaranteed this peer will always be valid regardless of any ref counting.  The event can not be removed in clear_peer_mailboxes until the event lock is grabbed, if the mwi_event_cb is taking place at that exact moment then the event lock is held in that thread.  This syncs the threads up in a way that prevents the peer pointer from existing in the mwi_event_cb after destruction.
> >     
> >     This is why the clear_peer_mailboxes(peer) call was moved to the top of the destructor.  We don't want to start tearing down peer information if the peer is somehow in the mwi_event_cb function before the event is removed.  Note that richard's patch moves the clear_peer_mailboxes(peer) call up as well. So depending on who commits first, this may already be done.
> >     
> >     Hope this makes sense.

Done.


> On Nov. 4, 2011, 12:03 p.m., David Vossel wrote:
> > trunk/channels/chan_sip.c, lines 14757-14761
> > <https://reviewboard.asterisk.org/r/1563/diff/2/?file=21625#file21625line14757>
> >
> >     I believe the peer already has a ref in this function, so the ref bumping should not be necessary.
> >     
> >     Unlocking the pvt however is a good idea, nice catch.

Done.


- opticron


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1563/#review4686
-----------------------------------------------------------


On Nov. 4, 2011, 1 p.m., opticron wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1563/
> -----------------------------------------------------------
> 
> (Updated Nov. 4, 2011, 1 p.m.)
> 
> 
> Review request for Asterisk Developers and David Vossel.
> 
> 
> Summary
> -------
> 
> Fix a locking inversion that causes deadlocks during BLF subscriptions.
> 
> 
> This addresses bug ASTERISK-18663.
>     https://issues.asterisk.org/jira/browse/ASTERISK-18663
> 
> 
> Diffs
> -----
> 
>   trunk/channels/chan_sip.c 342600 
> 
> Diff: https://reviewboard.asterisk.org/r/1563/diff
> 
> 
> Testing
> -------
> 
> Compile
> 
> 
> Thanks,
> 
> opticron
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20111104/2ee64c15/attachment-0001.htm>


More information about the asterisk-dev mailing list