Bridging: Use a ref to bridge_channel's channel to prevent crash.

There's a race condition with bridging where a bridge can be torn down
causing the bridge_channel's ast_channel to become NULL when it's still
needed. This particular case happened with attended transfers, but the
crash occurred when trying to publish a stasis message. Now, the
bridge_channel is locked, a ref to the ast_channel is obtained, and that
ref is passed down the chain.

Change-Id: Ic48715c0c041615d17d286790ae3e8c61bb28814
This commit is contained in:
Ben Ford
2020-08-31 11:14:20 -05:00
committed by Joshua Colp
parent bd0724c7ed
commit e7620d034a
3 changed files with 52 additions and 3 deletions

View File

@@ -193,6 +193,20 @@ struct ast_bridge_channel {
} stream_map;
};
/*!
* \brief Get a ref to the bridge_channel's ast_channel
*
* \param bridge_channel The bridge channel
*
* \note The returned channel NEEDS to be unref'd once you are done with it. In general, this
* function is best used when accessing the bridge_channel chan from outside of a bridging
* thread.
*
* \retval ref'd ast_channel on success
* \retval NULL otherwise
*/
struct ast_channel *ast_bridge_channel_get_chan(struct ast_bridge_channel *bridge_channel);
/*!
* \brief Try locking the bridge_channel.
*