Hold the lock properly on async goto now that we have recursive mutex support.
authorMark Spencer <markster@digium.com>
Mon, 19 Apr 2004 23:00:50 +0000 (23:00 +0000)
committerMark Spencer <markster@digium.com>
Mon, 19 Apr 2004 23:00:50 +0000 (23:00 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2713 65c4cc65-6c06-0410-ace0-fbb531ad65f3

pbx.c

diff --git a/pbx.c b/pbx.c
index e78fc2a..cdf57e0 100755 (executable)
--- a/pbx.c
+++ b/pbx.c
@@ -3530,7 +3530,6 @@ int ast_async_goto(struct ast_channel *chan, char *context, char *exten, int pri
                if (priority)
                        chan->priority = priority - 1;
                ast_softhangup_nolock(chan, AST_SOFTHANGUP_ASYNCGOTO);
-               ast_mutex_unlock(&chan->lock);
        } else {
                /* In order to do it when the channel doesn't really exist within
                   the PBX, we have to make a new channel, masquerade, and start the PBX
@@ -3560,8 +3559,6 @@ int ast_async_goto(struct ast_channel *chan, char *context, char *exten, int pri
                        /* Masquerade into temp channel */
                        ast_channel_masquerade(tmpchan, chan);
                
-                       ast_mutex_unlock(&chan->lock);
-
                        /* Grab the locks and get going */
                        ast_mutex_lock(&tmpchan->lock);
                        ast_do_masquerade(tmpchan);
@@ -3574,9 +3571,9 @@ int ast_async_goto(struct ast_channel *chan, char *context, char *exten, int pri
                        }
                } else {
                        res = -1;
-                       ast_mutex_unlock(&chan->lock);
                }
        }
+       ast_mutex_unlock(&chan->lock);
        return res;
 }