diff options
author | Kevin Harwell <kharwell@digium.com> | 2013-12-18 20:33:37 +0000 |
---|---|---|
committer | Kevin Harwell <kharwell@digium.com> | 2013-12-18 20:33:37 +0000 |
commit | 28c0cb28d0815e5e59ab99b60ac6b50e1ed9cbae (patch) | |
tree | b42967f4899ba28aea79b9a11827c814b95b62c8 /main/bridge_channel.c | |
parent | 86b5e11607e2e3b7dcfb0b72d41b492ce868f31c (diff) |
channel locking: Add locking for channel snapshot creation
Original commit message by mmichelson (asterisk 12 r403311):
"This adds channel locks around calls to create channel snapshots as well
as other functions which operate on a channel and then end up
creating a channel snapshot. Functions that expect the channel to be
locked prior to being called have had their documentation updated to
indicate such."
The above was initially committed and then reverted at r403398. The problem
was found to be in core_local.c in the publish_local_bridge_message function.
The ast_unreal_lock_all function locks and adds a reference to the returned
channels and while they were being unlocked they were not being unreffed when
no longer needed. Fixed by unreffing the channels.
Also in bridge.c a lock was obtained on "other->chan", but then an attempt was
made to unlock "other" and not the previously locked channel. Fixed by
unlocking "other->chan"
(closes issue ASTERISK-22709)
Reported by: John Bigelow
........
Merged revisions 404237 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404260 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/bridge_channel.c')
-rw-r--r-- | main/bridge_channel.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/main/bridge_channel.c b/main/bridge_channel.c index 96bfb209a..ae33cd056 100644 --- a/main/bridge_channel.c +++ b/main/bridge_channel.c @@ -235,12 +235,16 @@ void ast_bridge_channel_update_linkedids(struct ast_bridge_channel *bridge_chann return; } + ast_channel_lock(bridge_channel->chan); ast_channel_linkedid_set(bridge_channel->chan, oldest_linkedid); + ast_channel_unlock(bridge_channel->chan); AST_LIST_TRAVERSE(&bridge->channels, other, entry) { if (other == swap) { continue; } + ast_channel_lock(other->chan); ast_channel_linkedid_set(other->chan, oldest_linkedid); + ast_channel_unlock(other->chan); } } @@ -253,6 +257,7 @@ void ast_bridge_channel_update_accountcodes(struct ast_bridge_channel *bridge_ch if (other == swap) { continue; } + ast_channel_lock_both(bridge_channel->chan, other->chan); if (!ast_strlen_zero(ast_channel_accountcode(bridge_channel->chan)) && ast_strlen_zero(ast_channel_peeraccount(other->chan))) { ast_debug(1, "Setting peeraccount to %s for %s from data on channel %s\n", @@ -286,6 +291,8 @@ void ast_bridge_channel_update_accountcodes(struct ast_bridge_channel *bridge_ch ast_channel_peeraccount_set(bridge_channel->chan, ast_channel_accountcode(other->chan)); } } + ast_channel_unlock(bridge_channel->chan); + ast_channel_unlock(other->chan); } } @@ -624,14 +631,18 @@ int ast_bridge_channel_write_hold(struct ast_bridge_channel *bridge_channel, con datalen = 0; } + ast_channel_lock(bridge_channel->chan); ast_channel_publish_blob(bridge_channel->chan, ast_channel_hold_type(), blob); + ast_channel_unlock(bridge_channel->chan); return ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_HOLD, moh_class, datalen); } int ast_bridge_channel_write_unhold(struct ast_bridge_channel *bridge_channel) { + ast_channel_lock(bridge_channel->chan); ast_channel_publish_blob(bridge_channel->chan, ast_channel_unhold_type(), NULL); + ast_channel_unlock(bridge_channel->chan); return ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_UNHOLD, NULL, 0); } |