[asterisk-dev] [Code Review] Fix deadlock between subscription event RWLOCK and dialogs container lock in chan_sip.

rmudgett reviewboard at asterisk.org
Wed Nov 2 20:25:12 CDT 2011


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

(Updated Nov. 2, 2011, 8:25 p.m.)


Review request for Asterisk Developers and David Vossel.


Changes
-------

Merged the needdestroy container patch from schmidts unleash-the-beast branch.

Fixed a few issues with the new containers:
1) Changing the callid requires unlink/change/link process because the container uses the callid as the hash key.
2) check_rtp_timeout() still needs to protect from a null rtp pointer.
3) Failure to create the two new containers should cause chan_sip load to fail.


Summary
-------

Timing between dialog destruction and a MWI event sending a message could result in a deadlock.

Order of events causing deadlock:

1a) The event subscription system calls the registered callbacks with its list RWLOCK held.
1b) The SIP monitor checks for dialogs needing destruction.  It does an ao2_callback that holds the dialogs container lock while searching for dialogs to destroy.
2a) The event subscription SIP callback needs to create a temporary dialog to send out the MWI notification.  That temporary dialog needs to be inserted in the dialogs container so it must wait.
2b) The dialog search finds a dialog to destroy and as a result releases the last reference for a peer.  The peer destructor attempts to get the subscription RWLOCK but must wait.
3) deadlock


This addresses bug ASTERISK-18747.
    https://issues.asterisk.org/jira/browse/ASTERISK-18747


Diffs (updated)
-----

  /branches/1.8/channels/chan_sip.c 343275 

Diff: https://reviewboard.asterisk.org/r/1557/diff


Testing
-------

It compiles. :)


Thanks,

rmudgett

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20111103/466f6813/attachment.htm>


More information about the asterisk-dev mailing list