Fix deadlock if peer is destroyed while sending MWI notice.
authorRichard Mudgett <rmudgett@digium.com>
Mon, 7 Nov 2011 19:54:09 +0000 (19:54 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Mon, 7 Nov 2011 19:54:09 +0000 (19:54 +0000)
commit7a5f6684f05e03c51b5d004156dba9df2711dd50
tree5615007199f6562a742de6f54533eb666eb17014
parentf3c03ac1ecd9f8dec32edeaf9b1c3efd6a7e9e50
Fix deadlock if peer is destroyed while sending MWI notice.

A dialog cannot be destroyed by the ao2_callback dialog_needdestroy
because of a deadlock between the dialogs container lock and the RWLOCK of
the events subscription list.

* Create dialogs_to_destroy container to hold dialogs that will be
destroyed.

* Ensure that the event subscription callback will never happen with an
invalid peer pointer by making the event callback removal the first thing
in the peer destructor callback.

NOTE: This particular deadlock will not happen with Asterisk 10, but some
of the changes still apply.

(closes issue ASTERISK-18747)
Reported by: Gregory Hinton Nietsky

Review: https://reviewboard.asterisk.org/r/1564/
........

Merged revisions 343577 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 343578 from http://svn.asterisk.org/svn/asterisk/branches/10

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@343579 65c4cc65-6c06-0410-ace0-fbb531ad65f3
channels/chan_sip.c