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/stasis_bridges.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/stasis_bridges.c')
-rw-r--r-- | main/stasis_bridges.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/main/stasis_bridges.c b/main/stasis_bridges.c index 7f6679b00..b8d4ae8e1 100644 --- a/main/stasis_bridges.c +++ b/main/stasis_bridges.c @@ -399,7 +399,9 @@ struct stasis_message *ast_bridge_blob_create( } if (chan) { + ast_channel_lock(chan); obj->channel = ast_channel_snapshot_create(chan); + ast_channel_unlock(chan); if (obj->channel == NULL) { return NULL; } @@ -583,7 +585,9 @@ static int bridge_channel_snapshot_pair_init(struct ast_bridge_channel_pair *pai } } + ast_channel_lock(pair->channel); snapshot_pair->channel_snapshot = ast_channel_snapshot_create(pair->channel); + ast_channel_unlock(pair->channel); if (!snapshot_pair->channel_snapshot) { return -1; } @@ -919,7 +923,9 @@ void ast_bridge_publish_attended_transfer_link(int is_external, enum ast_transfe transfer_msg->dest_type = AST_ATTENDED_TRANSFER_DEST_LINK; for (i = 0; i < 2; ++i) { + ast_channel_lock(locals[i]); transfer_msg->dest.links[i] = ast_channel_snapshot_create(locals[i]); + ast_channel_unlock(locals[i]); if (!transfer_msg->dest.links[i]) { return; } |