[Asterisk-code-review] features: Bridge application's BRIDGERESULT not appropriatel... (asterisk[15])

Kevin Harwell asteriskteam at digium.com
Tue Oct 31 15:25:18 CDT 2017


Kevin Harwell has uploaded this change for review. ( https://gerrit.asterisk.org/6947


Change subject: features: Bridge application's BRIDGERESULT not appropriately set
......................................................................

features: Bridge application's BRIDGERESULT not appropriately set

The dialplan application "Bridge" was not setting the BRIDGERESULT to failure
when a failure did occur. Even worse if it did fail to join the bridge it would
still report success.

This patch now sets the BRIDGERESULT variable to an appropriate value for a
given condition state. Also, removed the value INCOMPATIBLE as a valid result
type since it is no longer used.

ASTERISK-27369 #close

Change-Id: I22588e7125a765edf35cff28c98ca143e9927554
---
M main/features.c
1 file changed, 10 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/47/6947/1

diff --git a/main/features.c b/main/features.c
index 61d9e51..516c64a 100644
--- a/main/features.c
+++ b/main/features.c
@@ -196,7 +196,6 @@
 					<value name="FAILURE" />
 					<value name="LOOP" />
 					<value name="NONEXISTENT" />
-					<value name="INCOMPATIBLE" />
 				</variable>
 			</variablelist>
 		</description>
@@ -1006,6 +1005,7 @@
 	const char *extension;
 	int priority;
 	int bridge_add_failed;
+	int res = -1;
 	struct ast_bridge_features chan_features;
 	struct ast_bridge_features *peer_features;
 	struct ast_bridge *bridge;
@@ -1032,6 +1032,7 @@
 	if (!current_dest_chan) {
 		ast_log(LOG_WARNING, "Bridge failed because channel %s does not exist\n",
 			args.dest_chan);
+		pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "NONEXISTENT");
 		return 0;
 	}
 
@@ -1039,13 +1040,13 @@
 	if (chan == current_dest_chan) {
 		ast_channel_unref(current_dest_chan);
 		ast_log(LOG_WARNING, "Unable to bridge channel %s with itself\n", ast_channel_name(chan));
+		pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "LOOP");
 		return 0;
 	}
 
 	if (ast_test_flag(&opts, OPT_DURATION_LIMIT)
 		&& !ast_strlen_zero(opt_args[OPT_ARG_DURATION_LIMIT])
 		&& ast_bridge_timelimit(chan, &bconfig, opt_args[OPT_ARG_DURATION_LIMIT], &calldurationlimit)) {
-		pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "FAILURE");
 		goto done;
 	}
 
@@ -1124,14 +1125,18 @@
 	/* Don't keep the channel ref in case it was not already in a bridge. */
 	current_dest_chan = ast_channel_unref(current_dest_chan);
 
-	ast_bridge_join(bridge, chan, NULL, &chan_features, NULL,
+	res = ast_bridge_join(bridge, chan, NULL, &chan_features, NULL,
 		AST_BRIDGE_JOIN_PASS_REFERENCE);
 
 	ast_bridge_features_cleanup(&chan_features);
 
-	/* The bridge has ended, set BRIDGERESULT to SUCCESS. */
-	pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "SUCCESS");
 done:
+	if (res == -1) {
+		pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "FAILURE");
+	} else {
+		pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "SUCCESS");
+	}
+
 	ast_free((char *) bconfig.warning_sound);
 	ast_free((char *) bconfig.end_sound);
 	ast_free((char *) bconfig.start_sound);

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

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: I22588e7125a765edf35cff28c98ca143e9927554
Gerrit-Change-Number: 6947
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171031/4107d245/attachment.html>


More information about the asterisk-code-review mailing list