summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2012-06-06 00:54:20 +0000
committerRichard Mudgett <rmudgett@digium.com>2012-06-06 00:54:20 +0000
commitfaacb8ba5283ccfdcc1e079f683e24c30db4f20f (patch)
tree6726c295ccb496af76a35e8b76caa02398d60ddd /main
parent37677a8cc26efe0ff7a1edb02a82feaa9695ae31 (diff)
Make builtin_blindtransfer() fully use ast_async_goto() abilities.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368566 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r--main/features.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/main/features.c b/main/features.c
index 21d6edca2..dd6357713 100644
--- a/main/features.c
+++ b/main/features.c
@@ -2423,7 +2423,7 @@ static int builtin_blindtransfer(struct ast_channel *chan, struct ast_channel *p
ast_debug(1, "Executing Blind Transfer %s, %s (sense=%d) \n", ast_channel_name(chan), ast_channel_name(peer), sense);
set_peers(&transferer, &transferee, peer, chan, sense);
- transferer_real_context = real_ctx(transferer, transferee);
+ transferer_real_context = ast_strdupa(real_ctx(transferer, transferee));
/* Start autoservice on transferee while we talk to the transferer */
ast_autoservice_start(transferee);
@@ -2471,7 +2471,8 @@ static int builtin_blindtransfer(struct ast_channel *chan, struct ast_channel *p
pbx_builtin_setvar_helper(transferee, "BLINDTRANSFER", ast_channel_name(transferer));
finishup(transferee);
ast_channel_lock(transferer);
- if (!ast_channel_cdr(transferer)) { /* this code should never get called (in a perfect world) */
+ if (!ast_channel_cdr(transferer)) {
+ /* this code should never get called (in a perfect world) */
ast_channel_cdr_set(transferer, ast_cdr_alloc());
if (ast_channel_cdr(transferer)) {
ast_cdr_init(ast_channel_cdr(transferer), transferer); /* initialize our channel's cdr */
@@ -2496,26 +2497,18 @@ static int builtin_blindtransfer(struct ast_channel *chan, struct ast_channel *p
ast_channel_cdr_set(transferer, ast_channel_cdr(transferee));
ast_channel_cdr_set(transferee, swap);
}
- if (!ast_channel_pbx(transferee)) {
- /* Doh! Use our handy async_goto functions */
- ast_debug(1, "About to ast_async_goto %s.\n", ast_channel_name(transferee));
- if (ast_async_goto(transferee, transferer_real_context, xferto, 1)) {
- ast_log(LOG_WARNING, "Async goto failed :-(\n");
- }
- /* The transferee is masqueraded and the original bridged channels can be hungup. */
- res = -1;
- } else {
- /* Set the transferee's new extension, since it exists, using transferer context */
- ast_debug(1, "About to explicit goto %s, it has a PBX.\n", ast_channel_name(transferee));
- ast_set_flag(ast_channel_flags(transferee), AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */
- set_c_e_p(transferee, transferer_real_context, xferto, 0);
+ res = ast_channel_pbx(transferee) ? AST_FEATURE_RETURN_SUCCESSBREAK : -1;
- /*
- * Break the bridge. The transferee needs to resume executing
- * dialplan at the xferto location.
- */
- res = AST_FEATURE_RETURN_SUCCESSBREAK;
+ /* Doh! Use our handy async_goto functions */
+ if (ast_async_goto(transferee, transferer_real_context, xferto, 1)) {
+ ast_log(LOG_WARNING, "Async goto failed :-(\n");
+ res = -1;
+ } else if (res == AST_FEATURE_RETURN_SUCCESSBREAK) {
+ /* Don't let the after-bridge code run the h-exten */
+ ast_channel_lock(transferee);
+ ast_set_flag(ast_channel_flags(transferee), AST_FLAG_BRIDGE_HANGUP_DONT);
+ ast_channel_unlock(transferee);
}
check_goto_on_transfer(transferer);
return res;