mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
Merge "Bridge system: Fix memory leaks and double frees on impart failure."
This commit is contained in:
@@ -199,7 +199,6 @@ int conf_announce_channel_push(struct ast_channel *ast)
|
|||||||
/* Impart the output channel into the bridge */
|
/* Impart the output channel into the bridge */
|
||||||
if (ast_bridge_impart(p->bridge, chan, NULL, features,
|
if (ast_bridge_impart(p->bridge, chan, NULL, features,
|
||||||
AST_BRIDGE_IMPART_CHAN_DEPARTABLE)) {
|
AST_BRIDGE_IMPART_CHAN_DEPARTABLE)) {
|
||||||
ast_bridge_features_destroy(features);
|
|
||||||
ast_channel_unref(chan);
|
ast_channel_unref(chan);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@@ -51,6 +51,7 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
|
|||||||
/*!
|
/*!
|
||||||
* \brief Bridge a call, and add additional flags to the bridge
|
* \brief Bridge a call, and add additional flags to the bridge
|
||||||
*
|
*
|
||||||
|
* \details
|
||||||
* This does the same thing as \ref ast_bridge_call, except that once the bridge
|
* This does the same thing as \ref ast_bridge_call, except that once the bridge
|
||||||
* is created, the provided flags are set on the bridge. The provided flags are
|
* is created, the provided flags are set on the bridge. The provided flags are
|
||||||
* added to the bridge's flags; they will not clear any flags already set.
|
* added to the bridge's flags; they will not clear any flags already set.
|
||||||
@@ -70,6 +71,7 @@ int ast_bridge_call_with_flags(struct ast_channel *chan, struct ast_channel *pee
|
|||||||
* \brief Add an arbitrary channel to a bridge
|
* \brief Add an arbitrary channel to a bridge
|
||||||
* \since 12.0.0
|
* \since 12.0.0
|
||||||
*
|
*
|
||||||
|
* \details
|
||||||
* The channel that is being added to the bridge can be in any state: unbridged,
|
* The channel that is being added to the bridge can be in any state: unbridged,
|
||||||
* bridged, answered, unanswered, etc. The channel will be added asynchronously,
|
* bridged, answered, unanswered, etc. The channel will be added asynchronously,
|
||||||
* meaning that when this function returns once the channel has been added to
|
* meaning that when this function returns once the channel has been added to
|
||||||
@@ -87,11 +89,16 @@ int ast_bridge_call_with_flags(struct ast_channel *chan, struct ast_channel *pee
|
|||||||
* \param features Features for this channel in the bridge
|
* \param features Features for this channel in the bridge
|
||||||
* \param play_tone Indicates if a tone should be played to the channel
|
* \param play_tone Indicates if a tone should be played to the channel
|
||||||
* \param xfersound Sound that should be used to indicate transfer with play_tone
|
* \param xfersound Sound that should be used to indicate transfer with play_tone
|
||||||
|
*
|
||||||
|
* \note The features parameter must be NULL or obtained by
|
||||||
|
* ast_bridge_features_new(). You must not dereference features
|
||||||
|
* after calling even if the call fails.
|
||||||
|
*
|
||||||
* \retval 0 Success
|
* \retval 0 Success
|
||||||
* \retval -1 Failure
|
* \retval -1 Failure
|
||||||
*/
|
*/
|
||||||
int ast_bridge_add_channel(struct ast_bridge *bridge, struct ast_channel *chan,
|
int ast_bridge_add_channel(struct ast_bridge *bridge, struct ast_channel *chan,
|
||||||
struct ast_bridge_features *features, int play_tone, const char *xfersound);
|
struct ast_bridge_features *features, int play_tone, const char *xfersound);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -2485,6 +2485,9 @@ int ast_bridge_add_channel(struct ast_bridge *bridge, struct ast_channel *chan,
|
|||||||
if (chan_bridge) {
|
if (chan_bridge) {
|
||||||
struct ast_bridge_channel *bridge_channel;
|
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);
|
ast_bridge_lock_both(bridge, chan_bridge);
|
||||||
bridge_channel = bridge_find_channel(chan_bridge, chan);
|
bridge_channel = bridge_find_channel(chan_bridge, chan);
|
||||||
|
|
||||||
@@ -2507,9 +2510,6 @@ int ast_bridge_add_channel(struct ast_bridge *bridge, struct ast_channel *chan,
|
|||||||
bridge_dissolve_check_stolen(chan_bridge, bridge_channel);
|
bridge_dissolve_check_stolen(chan_bridge, bridge_channel);
|
||||||
ast_bridge_unlock(chan_bridge);
|
ast_bridge_unlock(chan_bridge);
|
||||||
ast_bridge_unlock(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 {
|
} else {
|
||||||
/* Slightly less easy case. We need to yank channel A from
|
/* Slightly less easy case. We need to yank channel A from
|
||||||
* where he currently is and impart him into our bridge.
|
* where he currently is and impart him into our bridge.
|
||||||
@@ -2517,6 +2517,7 @@ int ast_bridge_add_channel(struct ast_bridge *bridge, struct ast_channel *chan,
|
|||||||
yanked_chan = ast_channel_yank(chan);
|
yanked_chan = ast_channel_yank(chan);
|
||||||
if (!yanked_chan) {
|
if (!yanked_chan) {
|
||||||
ast_log(LOG_WARNING, "Could not gain control of channel %s\n", ast_channel_name(chan));
|
ast_log(LOG_WARNING, "Could not gain control of channel %s\n", ast_channel_name(chan));
|
||||||
|
ast_bridge_features_destroy(features);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (ast_channel_state(yanked_chan) != AST_STATE_UP) {
|
if (ast_channel_state(yanked_chan) != AST_STATE_UP) {
|
||||||
|
@@ -805,7 +805,6 @@ int ast_unreal_channel_push_to_bridge(struct ast_channel *ast, struct ast_bridge
|
|||||||
/* Impart the semi2 channel into the bridge */
|
/* Impart the semi2 channel into the bridge */
|
||||||
if (ast_bridge_impart(bridge, chan, NULL, features,
|
if (ast_bridge_impart(bridge, chan, NULL, features,
|
||||||
AST_BRIDGE_IMPART_CHAN_INDEPENDENT)) {
|
AST_BRIDGE_IMPART_CHAN_INDEPENDENT)) {
|
||||||
ast_bridge_features_destroy(features);
|
|
||||||
ast_channel_unref(chan);
|
ast_channel_unref(chan);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@@ -1103,7 +1103,6 @@ static int bridge_exec(struct ast_channel *chan, const char *data)
|
|||||||
xfer_cfg ? xfer_cfg->xfersound : NULL);
|
xfer_cfg ? xfer_cfg->xfersound : NULL);
|
||||||
ao2_cleanup(xfer_cfg);
|
ao2_cleanup(xfer_cfg);
|
||||||
if (bridge_add_failed) {
|
if (bridge_add_failed) {
|
||||||
ast_bridge_features_destroy(peer_features);
|
|
||||||
ast_bridge_features_cleanup(&chan_features);
|
ast_bridge_features_cleanup(&chan_features);
|
||||||
ast_bridge_destroy(bridge, 0);
|
ast_bridge_destroy(bridge, 0);
|
||||||
goto done;
|
goto done;
|
||||||
|
Reference in New Issue
Block a user