Index: asterisk-13.17.2/main/features.c =================================================================== --- asterisk-13.17.2.orig/main/features.c 2017-10-23 13:15:47.423035578 -0300 +++ asterisk-13.17.2/main/features.c 2017-10-23 13:15:47.419035554 -0300 @@ -1009,6 +1009,7 @@ const char *extension; int priority; int bridge_add_failed; + int res; struct ast_bridge_features chan_features; struct ast_bridge_features *peer_features; struct ast_bridge *bridge; @@ -1089,18 +1090,21 @@ if (ast_bridge_features_init(&chan_features)) { ast_bridge_features_cleanup(&chan_features); + pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "FAILURE"); goto done; } peer_features = ast_bridge_features_new(); if (!peer_features) { ast_bridge_features_cleanup(&chan_features); + pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "FAILURE"); goto done; } if (pre_bridge_setup(chan, current_dest_chan, &bconfig, &chan_features, peer_features)) { ast_bridge_features_destroy(peer_features); ast_bridge_features_cleanup(&chan_features); + pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "FAILURE"); goto done; } @@ -1108,6 +1112,7 @@ if (!bridge) { ast_bridge_features_destroy(peer_features); ast_bridge_features_cleanup(&chan_features); + pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "FAILURE"); goto done; } @@ -1121,19 +1126,24 @@ if (bridge_add_failed) { ast_bridge_features_cleanup(&chan_features); ast_bridge_destroy(bridge, 0); + pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "FAILURE"); goto done; } /* 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"); + if (res == -1) { + pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "FAILURE"); + } else { + pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "SUCCESS"); + } done: ast_free((char *) bconfig.warning_sound); ast_free((char *) bconfig.end_sound);