[Asterisk-code-review] bridge channel.c: Fix Deadlock when using Local channels and... (asterisk[13])

Pirmin Walthert asteriskteam at digium.com
Wed May 30 01:24:49 CDT 2018


Pirmin Walthert has uploaded this change for review. ( https://gerrit.asterisk.org/9069


Change subject: bridge_channel.c: Fix Deadlock when using Local channels and fax gateway
......................................................................

bridge_channel.c: Fix Deadlock when using Local channels and fax gateway

ast_indicate is invoked with the bridge locked. As ast_indicate locks the
other end of the bridge as well this can lead to a deadlock in some situations.
(Especially when a different thread does the same in the reverse order).
This patch calls ast_indicate after unlocking the bridge, what fixes the
deadlock. Calling ast_indicate with these parameters without locking the
bridge should be safe as this is done at different places without a
bridge lock.

Change-Id: I5f86c1e2ce75b9929a36ab589b18c450e62ea35f
---
M main/bridge_channel.c
1 file changed, 6 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/69/9069/1

diff --git a/main/bridge_channel.c b/main/bridge_channel.c
index 3eefd44..1a7df87 100644
--- a/main/bridge_channel.c
+++ b/main/bridge_channel.c
@@ -2677,6 +2677,7 @@
 int bridge_channel_internal_join(struct ast_bridge_channel *bridge_channel)
 {
 	int res = 0;
+	uint8_t indicate_src_change = 0;
 	struct ast_bridge_features *channel_features;
 	struct ast_channel *swap;
 
@@ -2746,7 +2747,7 @@
 		 */
 		if (!(bridge_channel->bridge->technology->capabilities
 			& AST_BRIDGE_CAPABILITY_MULTIMIX)) {
-			ast_indicate(bridge_channel->chan, AST_CONTROL_SRCCHANGE);
+			indicate_src_change = 1;
 		}
 
 		bridge_channel_impart_signal(bridge_channel->chan);
@@ -2756,6 +2757,10 @@
 		ao2_t_cleanup(swap, "Bridge push with swap successful");
 		swap = NULL;
 
+		if (indicate_src_change) {
+			ast_indicate(bridge_channel->chan, AST_CONTROL_SRCCHANGE);
+		}
+
 		bridge_channel_event_join_leave(bridge_channel, AST_BRIDGE_HOOK_TYPE_JOIN);
 
 		while (bridge_channel->state == BRIDGE_CHANNEL_STATE_WAIT) {

-- 
To view, visit https://gerrit.asterisk.org/9069
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f86c1e2ce75b9929a36ab589b18c450e62ea35f
Gerrit-Change-Number: 9069
Gerrit-PatchSet: 1
Gerrit-Owner: Pirmin Walthert <infos at nappsoft.ch>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180530/ef275955/attachment.html>


More information about the asterisk-code-review mailing list