]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
More deadlock avoidance code (this time between sip_monitor and sip_hangup)
authorTilghman Lesher <tilghman@meg.abyt.es>
Mon, 24 Dec 2007 16:17:01 +0000 (16:17 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Mon, 24 Dec 2007 16:17:01 +0000 (16:17 +0000)
Reported by: apsaras
Patch by: tilghman
(Closes issue #11413)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@94765 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 4cdf3549555e06e5747d4a57b4a43249fa908ddd..c33c747b4c8eeb08c270534f4affb17e958bcd4e 100644 (file)
@@ -15497,7 +15497,14 @@ restartsearch:
                   get back to this point every millisecond or less)
                */
                for (sip = iflist; !fastrestart && sip; sip = sip->next) {
-                       ast_mutex_lock(&sip->lock);
+                       /*! \note If we can't get a lock on an interface, skip it and come
+                        * back later. Note that there is the possibility of a deadlock with
+                        * sip_hangup otherwise, because sip_hangup is called with the channel
+                        * locked first, and the iface lock is attempted second.
+                        */
+                       if (ast_mutex_trylock(&sip->lock))
+                               continue;
+
                        /* Check RTP timeouts and kill calls if we have a timeout set and do not get RTP */
                        if (sip->rtp && sip->owner &&
                            (sip->owner->_state == AST_STATE_UP) &&