[asterisk-commits] mmichelson: trunk r394232 - /trunk/main/bridging_basic.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 12 16:02:01 CDT 2013


Author: mmichelson
Date: Fri Jul 12 16:01:51 2013
New Revision: 394232

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394232
Log:
Prevent potential race condition in multiparty basic bridges.

For more details about the race condition see the linked review
at the bottom of this commit

(closes issue ASTERISK-21882)
Reported by Matt Jordan

Review: https://reviewboard.asterisk.org/r/2663


Modified:
    trunk/main/bridging_basic.c

Modified: trunk/main/bridging_basic.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/bridging_basic.c?view=diff&rev=394232&r1=394231&r2=394232
==============================================================================
--- trunk/main/bridging_basic.c (original)
+++ trunk/main/bridging_basic.c Fri Jul 12 16:01:51 2013
@@ -99,9 +99,16 @@
  */
 static int basic_hangup_hook(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *hook_pvt)
 {
-/* BUGBUG Race condition.  If all parties but one hangup at the same time, the bridge may not be dissolved on the remaining party. */
+	int bridge_count = 0;
+	struct ast_bridge_channel *iter;
+
 	ast_bridge_channel_lock_bridge(bridge_channel);
-	if (2 < bridge_channel->bridge->num_channels) {
+	AST_LIST_TRAVERSE(&bridge->channels, iter, entry) {
+		if (iter != bridge_channel && iter->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
+			++bridge_count;
+		}
+	}
+	if (2 <= bridge_count) {
 		/* Just allow this channel to leave the multi-party bridge. */
 		ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
 	}




More information about the asterisk-commits mailing list