]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
When doing an async goto, detect if the channel is already in the middle of a
authorRussell Bryant <russell@russellbryant.com>
Mon, 8 Sep 2008 21:02:36 +0000 (21:02 +0000)
committerRussell Bryant <russell@russellbryant.com>
Mon, 8 Sep 2008 21:02:36 +0000 (21:02 +0000)
masquerade.  This can happen when chan_local is trying to optimize itself out.
If this happens, fail the async goto instead of bursting into flames.

(closes issue #13435)
Reported by: geoff2010

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

main/pbx.c

index f4dfd0d5278e93a0524d00206df360eabfbce614..9aa96118cae287c15dbfaef93f2fc8a0f4ab0611 100644 (file)
@@ -4609,17 +4609,23 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
                                S_OR(context, chan->context), S_OR(exten, chan->exten), priority);
 
                        /* Masquerade into temp channel */
-                       ast_channel_masquerade(tmpchan, chan);
-
-                       /* Grab the locks and get going */
-                       ast_channel_lock(tmpchan);
-                       ast_do_masquerade(tmpchan);
-                       ast_channel_unlock(tmpchan);
-                       /* Start the PBX going on our stolen channel */
-                       if (ast_pbx_start(tmpchan)) {
-                               ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmpchan->name);
+                       if (ast_channel_masquerade(tmpchan, chan)) {
+                               /* Failed to set up the masquerade.  It's probably chan_local
+                                * in the middle of optimizing itself out.  Sad. :( */
                                ast_hangup(tmpchan);
+                               tmpchan = NULL;
                                res = -1;
+                       } else {
+                               /* Grab the locks and get going */
+                               ast_channel_lock(tmpchan);
+                               ast_do_masquerade(tmpchan);
+                               ast_channel_unlock(tmpchan);
+                               /* Start the PBX going on our stolen channel */
+                               if (ast_pbx_start(tmpchan)) {
+                                       ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmpchan->name);
+                                       ast_hangup(tmpchan);
+                                       res = -1;
+                               }
                        }
                }
        }