[Asterisk-code-review] bridge basic.c: Fix GOTO ON BLINDXFR (asterisk[master])

Richard Mudgett asteriskteam at digium.com
Thu Dec 24 17:39:31 CST 2015


Richard Mudgett has uploaded a new change for review.

  https://gerrit.asterisk.org/1860

Change subject: bridge_basic.c: Fix GOTO_ON_BLINDXFR
......................................................................

bridge_basic.c: Fix GOTO_ON_BLINDXFR

Use of GOTO_ON_BLINDXFR would not work at all.  The target location would
never be executed by the transferring channel.

* Made feature_blind_transfer() call ast_bridge_set_after_go_on() with
valid context, exten, and priority parameters from the transferring
channel.

* Renamed some feature_blind_transfer() local variables for clarity.

ASTERISK-25641 #close
Reported by Dmitry Melekhov

Change-Id: I19bead9ffdc4aee8d58c654ca05a198da1e4b7ac
---
M main/bridge_basic.c
1 file changed, 19 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/60/1860/1

diff --git a/main/bridge_basic.c b/main/bridge_basic.c
index 5e20f30..cd19915 100644
--- a/main/bridge_basic.c
+++ b/main/bridge_basic.c
@@ -3383,35 +3383,46 @@
 /*! \brief Internal built in feature for blind transfers */
 static int feature_blind_transfer(struct ast_bridge_channel *bridge_channel, void *hook_pvt)
 {
-	char exten[AST_MAX_EXTENSION] = "";
+	char xfer_exten[AST_MAX_EXTENSION] = "";
 	struct ast_bridge_features_blind_transfer *blind_transfer = hook_pvt;
-	const char *context;
+	const char *xfer_context;
 	char *goto_on_blindxfr;
 
 	ast_bridge_channel_write_hold(bridge_channel, NULL);
 
 	ast_channel_lock(bridge_channel->chan);
-	context = ast_strdupa(get_transfer_context(bridge_channel->chan,
+	xfer_context = ast_strdupa(get_transfer_context(bridge_channel->chan,
 		blind_transfer ? blind_transfer->context : NULL));
 	goto_on_blindxfr = ast_strdupa(S_OR(pbx_builtin_getvar_helper(bridge_channel->chan,
 		"GOTO_ON_BLINDXFR"), ""));
 	ast_channel_unlock(bridge_channel->chan);
 
 	/* Grab the extension to transfer to */
-	if (grab_transfer(bridge_channel->chan, exten, sizeof(exten), context)) {
+	if (grab_transfer(bridge_channel->chan, xfer_exten, sizeof(xfer_exten), xfer_context)) {
 		ast_bridge_channel_write_unhold(bridge_channel);
 		return 0;
 	}
 
 	if (!ast_strlen_zero(goto_on_blindxfr)) {
+		const char *chan_context;
+		const char *chan_exten;
+		int chan_priority;
+
 		ast_debug(1, "After transfer, transferer %s goes to %s\n",
 				ast_channel_name(bridge_channel->chan), goto_on_blindxfr);
-		ast_bridge_set_after_go_on(bridge_channel->chan, NULL, NULL, 0, goto_on_blindxfr);
+
+		ast_channel_lock(bridge_channel->chan);
+		chan_context = ast_strdupa(ast_channel_context(bridge_channel->chan));
+		chan_exten = ast_strdupa(ast_channel_exten(bridge_channel->chan));
+		chan_priority = ast_channel_priority(bridge_channel->chan);
+		ast_channel_unlock(bridge_channel->chan);
+		ast_bridge_set_after_go_on(bridge_channel->chan,
+			chan_context, chan_exten, chan_priority, goto_on_blindxfr);
 	}
 
-	if (ast_bridge_transfer_blind(0, bridge_channel->chan, exten, context, blind_transfer_cb,
-			bridge_channel->chan) != AST_BRIDGE_TRANSFER_SUCCESS &&
-			!ast_strlen_zero(goto_on_blindxfr)) {
+	if (ast_bridge_transfer_blind(0, bridge_channel->chan, xfer_exten, xfer_context,
+		blind_transfer_cb, bridge_channel->chan) != AST_BRIDGE_TRANSFER_SUCCESS
+		&& !ast_strlen_zero(goto_on_blindxfr)) {
 		ast_bridge_discard_after_goto(bridge_channel->chan);
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/1860
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I19bead9ffdc4aee8d58c654ca05a198da1e4b7ac
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-code-review mailing list