]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
This resolves a deadlock that a tech support customer was getting frequently
authorRussell Bryant <russell@russellbryant.com>
Tue, 25 Jul 2006 19:43:38 +0000 (19:43 +0000)
committerRussell Bryant <russell@russellbryant.com>
Tue, 25 Jul 2006 19:43:38 +0000 (19:43 +0000)
when his users would answer call waiting. If another thread is currently
holding the zt_pvt lock for the first channel, unlock both channels and let
asterisk retry the native bridge, just like what is done for the second channel
directly below these changes.

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

channels/chan_zap.c

index 8f69f886f37b3e9c4409b6a0edf8caed6ffd4c55..2cd028a01f3e32e5e5a1e2392a2a00177072354a 100644 (file)
@@ -3047,7 +3047,13 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
        oc0 = p0->owner;
        oc1 = p1->owner;
 
-       ast_mutex_lock(&p0->lock);
+       if (ast_mutex_trylock(&p0->lock)) {
+               /* Don't block, due to potential for deadlock */
+               ast_mutex_unlock(&c0->lock);
+               ast_mutex_unlock(&c1->lock);
+               ast_log(LOG_NOTICE, "Avoiding deadlock...\n");
+               return AST_BRIDGE_RETRY;
+       }
        if (ast_mutex_trylock(&p1->lock)) {
                /* Don't block, due to potential for deadlock */
                ast_mutex_unlock(&p0->lock);