[Asterisk-code-review] bridge: Unlock channel during Local peer check. (asterisk[master])
Joshua Colp
asteriskteam at digium.com
Wed Jan 5 07:06:11 CST 2022
Joshua Colp has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/17743 )
Change subject: bridge: Unlock channel during Local peer check.
......................................................................
bridge: Unlock channel during Local peer check.
It's not safe to keep the channel locked while locking
the peer Local channel, as it can result in a deadlock.
This change unlocks it during this time but keeps the
bridge locked to ensure nothing changes about the bridge.
ASTERISK-29821
Change-Id: Ib68eb7037e5a479bcc2aceee77337cdde1fbdde6
---
M main/bridge_channel.c
1 file changed, 5 insertions(+), 2 deletions(-)
Approvals:
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Joshua Colp: Approved for Submit
diff --git a/main/bridge_channel.c b/main/bridge_channel.c
index 1f401c8..1b0f1dd 100644
--- a/main/bridge_channel.c
+++ b/main/bridge_channel.c
@@ -2861,11 +2861,13 @@
ast_bridge_lock(bridge_channel->bridge);
ast_channel_lock(bridge_channel->chan);
-
peer = ast_local_get_peer(bridge_channel->chan);
+
if (peer) {
struct ast_bridge *peer_bridge;
+ ast_channel_unlock(bridge_channel->chan);
+
ast_channel_lock(peer);
peer_bridge = ast_channel_internal_bridge(peer);
ast_channel_unlock(peer);
@@ -2875,7 +2877,6 @@
* to be reference counted or locked.
*/
if (peer_bridge == bridge_channel->bridge) {
- ast_channel_unlock(bridge_channel->chan);
ast_bridge_unlock(bridge_channel->bridge);
ast_debug(1, "Bridge %s: %p(%s) denying Bridge join to prevent Local channel loop\n",
bridge_channel->bridge->uniqueid,
@@ -2883,6 +2884,8 @@
ast_channel_name(bridge_channel->chan));
return -1;
}
+
+ ast_channel_lock(bridge_channel->chan);
}
bridge_channel->read_format = ao2_bump(ast_channel_readformat(bridge_channel->chan));
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/17743
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ib68eb7037e5a479bcc2aceee77337cdde1fbdde6
Gerrit-Change-Number: 17743
Gerrit-PatchSet: 2
Gerrit-Owner: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220105/bd8fff0b/attachment-0001.html>
More information about the asterisk-code-review
mailing list