summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2016-04-26 04:56:36 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2016-04-26 04:56:36 -0500
commit4efc6b43155452b2f9cb5f96c7aea4cdfc1a84d1 (patch)
treefad4c64e7f960c6bbe533f050af750b38ff5b61e /main
parent83dadc4683abcd10f0c4566abef541d997dcf5b8 (diff)
parent1e93f3d7232a2a087a190a18e4a3f490a41d42d1 (diff)
Merge changes from topic 'system_stress_patches' into 13
* changes: Bridge system: Fix memory leaks and double frees on impart failure. bridge_softmix.c: Fix crash if channel fails to join mixing tech.
Diffstat (limited to 'main')
-rw-r--r--main/bridge.c11
-rw-r--r--main/core_unreal.c1
-rw-r--r--main/features.c1
3 files changed, 7 insertions, 6 deletions
diff --git a/main/bridge.c b/main/bridge.c
index ee1d8cec6..ee5ad735b 100644
--- a/main/bridge.c
+++ b/main/bridge.c
@@ -420,10 +420,12 @@ static void bridge_channel_complete_join(struct ast_bridge *bridge, struct ast_b
bridge->technology->name);
if (bridge->technology->join
&& bridge->technology->join(bridge, bridge_channel)) {
- ast_debug(1, "Bridge %s: %p(%s) failed to join %s technology\n",
+ /* We cannot leave the channel partially in the bridge so we must kick it out */
+ ast_debug(1, "Bridge %s: %p(%s) failed to join %s technology (Kicking it out)\n",
bridge->uniqueid, bridge_channel, ast_channel_name(bridge_channel->chan),
bridge->technology->name);
bridge_channel->just_joined = 1;
+ ast_bridge_channel_leave_bridge(bridge_channel, BRIDGE_CHANNEL_STATE_END, 0);
return;
}
@@ -2485,6 +2487,9 @@ int ast_bridge_add_channel(struct ast_bridge *bridge, struct ast_channel *chan,
if (chan_bridge) {
struct ast_bridge_channel *bridge_channel;
+ /* The channel is in a bridge so it is not getting any new features. */
+ ast_bridge_features_destroy(features);
+
ast_bridge_lock_both(bridge, chan_bridge);
bridge_channel = bridge_find_channel(chan_bridge, chan);
@@ -2507,9 +2512,6 @@ int ast_bridge_add_channel(struct ast_bridge *bridge, struct ast_channel *chan,
bridge_dissolve_check_stolen(chan_bridge, bridge_channel);
ast_bridge_unlock(chan_bridge);
ast_bridge_unlock(bridge);
-
- /* The channel was in a bridge so it is not getting any new features. */
- ast_bridge_features_destroy(features);
} else {
/* Slightly less easy case. We need to yank channel A from
* where he currently is and impart him into our bridge.
@@ -2517,6 +2519,7 @@ int ast_bridge_add_channel(struct ast_bridge *bridge, struct ast_channel *chan,
yanked_chan = ast_channel_yank(chan);
if (!yanked_chan) {
ast_log(LOG_WARNING, "Could not gain control of channel %s\n", ast_channel_name(chan));
+ ast_bridge_features_destroy(features);
return -1;
}
if (ast_channel_state(yanked_chan) != AST_STATE_UP) {
diff --git a/main/core_unreal.c b/main/core_unreal.c
index e9b7a8d66..f2404dfca 100644
--- a/main/core_unreal.c
+++ b/main/core_unreal.c
@@ -808,7 +808,6 @@ int ast_unreal_channel_push_to_bridge(struct ast_channel *ast, struct ast_bridge
/* Impart the semi2 channel into the bridge */
if (ast_bridge_impart(bridge, chan, NULL, features,
AST_BRIDGE_IMPART_CHAN_INDEPENDENT)) {
- ast_bridge_features_destroy(features);
ast_channel_unref(chan);
return -1;
}
diff --git a/main/features.c b/main/features.c
index 1810b1556..b96cbd68c 100644
--- a/main/features.c
+++ b/main/features.c
@@ -1104,7 +1104,6 @@ static int bridge_exec(struct ast_channel *chan, const char *data)
xfer_cfg ? xfer_cfg->xfersound : NULL);
ao2_cleanup(xfer_cfg);
if (bridge_add_failed) {
- ast_bridge_features_destroy(peer_features);
ast_bridge_features_cleanup(&chan_features);
ast_bridge_destroy(bridge, 0);
goto done;