[asterisk-commits] rmudgett: branch group/bridge_construction r381014 - /team/group/bridge_const...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 6 18:50:52 CST 2013


Author: rmudgett
Date: Wed Feb  6 18:50:48 2013
New Revision: 381014

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=381014
Log:
Fixup some AST_BRIDGE_CHANNEL_STATE_DEPART_END use cases and use more switch state forms.

Modified:
    team/group/bridge_construction/main/bridging.c
    team/group/bridge_construction/main/features.c

Modified: team/group/bridge_construction/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/main/bridging.c?view=diff&rev=381014&r1=381013&r2=381014
==============================================================================
--- team/group/bridge_construction/main/bridging.c (original)
+++ team/group/bridge_construction/main/bridging.c Wed Feb  6 18:50:48 2013
@@ -309,12 +309,10 @@
 	AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
 		ao2_lock(bridge_channel);
 		switch (bridge_channel->state) {
-		case AST_BRIDGE_CHANNEL_STATE_END:
-		case AST_BRIDGE_CHANNEL_STATE_HANGUP:
-		case AST_BRIDGE_CHANNEL_STATE_DEPART:
+		case AST_BRIDGE_CHANNEL_STATE_WAIT:
+			ast_bridge_change_state_nolock(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
 			break;
 		default:
-			ast_bridge_change_state_nolock(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
 			break;
 		}
 		ao2_unlock(bridge_channel);
@@ -462,8 +460,12 @@
 		if (!frame || (frame->frametype == AST_FRAME_CONTROL && frame->subclass.integer == AST_CONTROL_HANGUP)) {
 			/* Signal the thread that is handling the bridged channel that it should be ended */
 			ao2_lock(bridge_channel);
-			if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
+			switch (bridge_channel->state) {
+			case AST_BRIDGE_CHANNEL_STATE_WAIT:
 				ast_bridge_change_state_nolock(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
+				break;
+			default:
+				break;
 			}
 			ao2_unlock(bridge_channel);
 		} else if (frame->frametype == AST_FRAME_CONTROL && bridge_drop_control_frame(frame->subclass.integer)) {
@@ -1170,8 +1172,12 @@
 		 */
 		if (bridge_channel->chan && ast_check_hangup_locked(bridge_channel->chan)) {
 			ao2_lock(bridge_channel);
-			if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
+			switch (bridge_channel->state) {
+			case AST_BRIDGE_CHANNEL_STATE_WAIT:
 				ast_bridge_change_state_nolock(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
+				break;
+			default:
+				break;
 			}
 			ao2_unlock(bridge_channel);
 		}
@@ -1311,8 +1317,12 @@
 		if (bridge_channel2) {
 			ast_debug(1, "Swapping bridge channel %p out from bridge %p so bridge channel %p can slip in\n", bridge_channel2, bridge_channel->bridge, bridge_channel);
 			ao2_lock(bridge_channel2);
-			if (bridge_channel2->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
+			switch (bridge_channel2->state) {
+			case AST_BRIDGE_CHANNEL_STATE_WAIT:
 				ast_bridge_change_state_nolock(bridge_channel2, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+				break;
+			default:
+				break;
 			}
 			ao2_unlock(bridge_channel2);
 		}
@@ -1418,11 +1428,16 @@
 	bridge_channel->bridge->num--;
 	AST_LIST_REMOVE(&bridge_channel->bridge->channels, bridge_channel, entry);
 
-	if (bridge_channel->depart_wait
-		&& bridge_channel->state != AST_BRIDGE_CHANNEL_STATE_DEPART
-		&& bridge_channel->state != AST_BRIDGE_CHANNEL_STATE_DEPART_END) {
-		/* Put the channel into the ast_bridge_depart wait list. */
-		AST_LIST_INSERT_TAIL(&bridge_channel->bridge->depart_wait, bridge_channel, entry);
+	if (bridge_channel->depart_wait) {
+		switch (bridge_channel->state) {
+		case AST_BRIDGE_CHANNEL_STATE_DEPART:
+		case AST_BRIDGE_CHANNEL_STATE_DEPART_END:
+			break;
+		default:
+			/* Put the channel into the ast_bridge_depart wait list. */
+			AST_LIST_INSERT_TAIL(&bridge_channel->bridge->depart_wait, bridge_channel, entry);
+			break;
+		}
 	}
 
 	bridge_array_remove(bridge_channel->bridge, bridge_channel->chan);
@@ -1569,14 +1584,13 @@
 /* BUGBUG need to determine where to execute in the dialplan. */
 	switch (state) {
 	case AST_BRIDGE_CHANNEL_STATE_DEPART:
+	case AST_BRIDGE_CHANNEL_STATE_DEPART_END:
 		ast_log(LOG_ERROR, "Independently imparted channel was departed: %s\n",
 			ast_channel_name(chan));
 		ast_assert(0);
 		/* fallthrough */
 	case AST_BRIDGE_CHANNEL_STATE_HANGUP:
 	case AST_BRIDGE_CHANNEL_STATE_END:
-		ast_hangup(chan);
-		break;
 	default:
 		ast_hangup(chan);
 		break;
@@ -1647,6 +1661,15 @@
 			case AST_BRIDGE_CHANNEL_STATE_END:
 				ast_bridge_change_state_nolock(bridge_channel, AST_BRIDGE_CHANNEL_STATE_DEPART_END);
 				break;
+			case AST_BRIDGE_CHANNEL_STATE_DEPART:
+			case AST_BRIDGE_CHANNEL_STATE_DEPART_END:
+				/*
+				 * Should never happen.  It likely means that
+				 * ast_bridge_depart() is called by two threads for the same
+				 * channel.
+				 */
+				ast_assert(0);
+				break;
 			default:
 				ast_bridge_change_state_nolock(bridge_channel, AST_BRIDGE_CHANNEL_STATE_DEPART);
 				break;
@@ -1694,8 +1717,12 @@
 	}
 
 	ao2_lock(bridge_channel);
-	if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
+	switch (bridge_channel->state) {
+	case AST_BRIDGE_CHANNEL_STATE_WAIT:
 		ast_bridge_change_state_nolock(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+		break;
+	default:
+		break;
 	}
 	ao2_unlock(bridge_channel);
 
@@ -1995,8 +2022,12 @@
 	}
 
 	ao2_lock(bridge_channel);
-	if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_WAIT){
+	switch (bridge_channel->state) {
+	case AST_BRIDGE_CHANNEL_STATE_WAIT:
 		ast_bridge_change_state_nolock(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+		break;
+	default:
+		break;
 	}
 	ao2_unlock(bridge_channel);
 

Modified: team/group/bridge_construction/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/main/features.c?view=diff&rev=381014&r1=381013&r2=381014
==============================================================================
--- team/group/bridge_construction/main/features.c (original)
+++ team/group/bridge_construction/main/features.c Wed Feb  6 18:50:48 2013
@@ -4672,27 +4672,21 @@
 	}
 
 	/* Join bridge */
+	ast_bridge_join(bridge, chan, NULL, &chan_features, NULL);
+
+	/*
+	 * If the bridge was broken for a hangup that isn't real, then
+	 * don't run the h extension, because the channel isn't really
+	 * hung up.  This should really only happen with
+	 * AST_SOFTHANGUP_ASYNCGOTO.
+	 */
 	res = -1;
-	switch (ast_bridge_join(bridge, chan, NULL, &chan_features, NULL)) {
-	case AST_BRIDGE_CHANNEL_STATE_END:
-	case AST_BRIDGE_CHANNEL_STATE_HANGUP:
-	case AST_BRIDGE_CHANNEL_STATE_DEPART:
-		/*
-		 * If the bridge was broken for a hangup that isn't real, then
-		 * don't run the h extension, because the channel isn't really
-		 * hung up.  This should really only happen with
-		 * AST_SOFTHANGUP_ASYNCGOTO.
-		 */
-		ast_channel_lock(chan);
-		if (ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_ASYNCGOTO) {
-			ast_set_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_DONT);
-			res = 0;
-		}
-		ast_channel_unlock(chan);
-		break;
-	default:
-		break;
-	}
+	ast_channel_lock(chan);
+	if (ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_ASYNCGOTO) {
+		ast_set_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_DONT);
+		res = 0;
+	}
+	ast_channel_unlock(chan);
 
 	/* Wait for peer thread to exit bridge and die. */
 	if (!ast_autoservice_start(chan)) {




More information about the asterisk-commits mailing list