]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Unset BRIDGEPEER when leaving a bridge 52/1752/1
authorJonathan Rose <jrose@digium.com>
Tue, 1 Dec 2015 22:11:07 +0000 (16:11 -0600)
committerJonathan Rose <jrose@digium.com>
Wed, 2 Dec 2015 18:57:04 +0000 (12:57 -0600)
Currently if a channel is transferred out of a bridge, the BRIDGEPEER
variable (also BRIDGEPVTCALLID) remain set even once the channel is
out of the bridge. This patch removes these variables when leaving
the bridge.

ASTERISK-25600 #close
Reported by: Mark Michelson

Change-Id: I753ead2fffbfc65427ed4e9244c7066610e546da

include/asterisk/bridge.h
main/bridge.c
main/bridge_channel.c

index fc3726270fbee2af7552305cc8284506c8f59a43..30ac0953c294c467f339717b58d19d106954caad 100644 (file)
@@ -746,6 +746,18 @@ int ast_bridge_suspend(struct ast_bridge *bridge, struct ast_channel *chan);
  */
 int ast_bridge_unsuspend(struct ast_bridge *bridge, struct ast_channel *chan);
 
+/*!
+ * \brief Sets BRIDGECHANNEL and BRIDGEPVTCALLID for a channel
+ *
+ * \pre chan must be locked before calling
+ *
+ * \param name channel name of the bridged peer
+ * \param pvtid Private CallID of the bridged peer
+ *
+ * \return nothing
+ */
+void ast_bridge_vars_set(struct ast_channel *chan, const char *name, const char *pvtid);
+
 struct ast_unreal_pvt;
 
 /*!
index 7644884ebef9a449f2272bec0f66948a104a9b5a..b5c59514c5b2c5ed83930faf3adb2799b9c768df 100644 (file)
@@ -1213,7 +1213,7 @@ static void check_bridge_play_sounds(struct ast_bridge *bridge)
        }
 }
 
-static void update_bridge_vars_set(struct ast_channel *chan, const char *name, const char *pvtid)
+void ast_bridge_vars_set(struct ast_channel *chan, const char *name, const char *pvtid)
 {
        ast_channel_stage_snapshot(chan);
        pbx_builtin_setvar_helper(chan, "BRIDGEPEER", name);
@@ -1253,12 +1253,12 @@ static void set_bridge_peer_vars_2party(struct ast_channel *c0, struct ast_chann
        ast_channel_unlock(c1);
 
        ast_channel_lock(c0);
-       update_bridge_vars_set(c0, c1_name, c1_pvtid);
+       ast_bridge_vars_set(c0, c1_name, c1_pvtid);
        UPDATE_BRIDGE_VARS_GET(c0, c0_name, c0_pvtid);
        ast_channel_unlock(c0);
 
        ast_channel_lock(c1);
-       update_bridge_vars_set(c1, c0_name, c0_pvtid);
+       ast_bridge_vars_set(c1, c0_name, c0_pvtid);
        ast_channel_unlock(c1);
 }
 
@@ -1359,7 +1359,7 @@ static void set_bridge_peer_vars_multiparty(struct ast_bridge *bridge)
                ++idx;
 
                ast_channel_lock(bridge_channel->chan);
-               update_bridge_vars_set(bridge_channel->chan, buf, NULL);
+               ast_bridge_vars_set(bridge_channel->chan, buf, NULL);
                ast_channel_unlock(bridge_channel->chan);
        }
 }
@@ -1381,7 +1381,7 @@ static void set_bridge_peer_vars_holding(struct ast_bridge *bridge)
 
        AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
                ast_channel_lock(bridge_channel->chan);
-               update_bridge_vars_set(bridge_channel->chan, NULL, NULL);
+               ast_bridge_vars_set(bridge_channel->chan, NULL, NULL);
                ast_channel_unlock(bridge_channel->chan);
        }
 }
index 8ce022005c84c4c7371130ff639d5e5f5e58cd3a..3874e50ff6deb54592a65f0459de6c23c54910e9 100644 (file)
@@ -289,6 +289,10 @@ void ast_bridge_channel_leave_bridge_nolock(struct ast_bridge_channel *bridge_ch
 
        channel_set_cause(bridge_channel->chan, cause);
 
+       ast_channel_lock(bridge_channel->chan);
+       ast_bridge_vars_set(bridge_channel->chan, NULL, NULL);
+       ast_channel_unlock(bridge_channel->chan);
+
        /* Change the state on the bridge channel */
        bridge_channel->state = new_state;