diff options
author | Richard Mudgett <rmudgett@digium.com> | 2013-06-08 05:18:22 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2013-06-08 05:18:22 +0000 |
commit | c88b7945f64ef713da3791e2518608c1e65e90de (patch) | |
tree | 26e5bf9e5c31678abc43f31da664b439ccfa0d1b /bridges | |
parent | 661f6d499e9e5c509d09d7775f64625b398143ac (diff) |
Fix a crash when a bridge switches from the softmix bridge technology to another.
A three party bridge uses the softmix bridging technology. This
technology has a dedicated thread used to perform the analog mixing. When
one of these parties leaves the bridge, the bridge technology is changed
from the softmix technology to a two-party mixing technology. Changing
technologies is done by removing channels from the old technology and
adding them to the new technology. Since the remaining channels do not
leave the bridge, the softmix mixing thread could continue to process all
channels in the bridge. If the bridge code is not able to start
destruction of the softmix technology before the softmix mixing thread
wakes up, a crash happens.
* Added a stop technology callback that technologies can use to request
any helper threads to stop in preparation for being destroyed.
(closes issue AST-1156)
Reported by: John Bigelow
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@390975 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'bridges')
-rw-r--r-- | bridges/bridge_softmix.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c index 2a65e0f86..ac183b28a 100644 --- a/bridges/bridge_softmix.c +++ b/bridges/bridge_softmix.c @@ -1064,6 +1064,29 @@ static int softmix_bridge_create(struct ast_bridge *bridge) return 0; } +/*! + * \internal + * \brief Request the softmix mixing thread stop. + * \since 12.0.0 + * + * \param bridge Which bridge is being stopped. + * + * \return Nothing + */ +static void softmix_bridge_stop(struct ast_bridge *bridge) +{ + struct softmix_bridge_data *softmix_data; + + softmix_data = bridge->tech_pvt; + if (!softmix_data) { + return; + } + + ast_mutex_lock(&softmix_data->lock); + softmix_data->stop = 1; + ast_mutex_unlock(&softmix_data->lock); +} + /*! \brief Function called when a bridge is destroyed */ static void softmix_bridge_destroy(struct ast_bridge *bridge) { @@ -1096,6 +1119,7 @@ static struct ast_bridge_technology softmix_bridge = { .capabilities = AST_BRIDGE_CAPABILITY_MULTIMIX, .preference = AST_BRIDGE_PREFERENCE_BASE_MULTIMIX, .create = softmix_bridge_create, + .stop = softmix_bridge_stop, .destroy = softmix_bridge_destroy, .join = softmix_bridge_join, .leave = softmix_bridge_leave, |