[asterisk-commits] mmichelson: branch mmichelson/bridged_channel r395808 - /team/mmichelson/brid...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 30 16:22:30 CDT 2013


Author: mmichelson
Date: Tue Jul 30 16:22:28 2013
New Revision: 395808

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395808
Log:
Remove chan_sip and chan_skinny's uses of ast_bridged_call


Modified:
    team/mmichelson/bridged_channel/channels/chan_sip.c
    team/mmichelson/bridged_channel/channels/chan_skinny.c

Modified: team/mmichelson/bridged_channel/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/bridged_channel/channels/chan_sip.c?view=diff&rev=395808&r1=395807&r2=395808
==============================================================================
--- team/mmichelson/bridged_channel/channels/chan_sip.c (original)
+++ team/mmichelson/bridged_channel/channels/chan_sip.c Tue Jul 30 16:22:28 2013
@@ -7270,7 +7270,7 @@
 			}
 
 			if (!p->pendinginvite) {
-				struct ast_channel *bridge = ast_bridged_channel(oldowner);
+				RAII_VAR(struct ast_channel *, bridge, ast_channel_bridge_peer(oldowner), ast_channel_cleanup);
 				char quality_buf[AST_MAX_USER_FIELD], *quality;
 
 				/* We need to get the lock on bridge because ast_rtp_instance_set_stats_vars will attempt
@@ -7281,7 +7281,6 @@
 					do {
 						CHANNEL_DEADLOCK_AVOIDANCE(oldowner);
 					} while (sip_pvt_trylock(p));
-					bridge = ast_bridged_channel(oldowner);
 				}
 
 				if (p->rtp) {
@@ -18006,10 +18005,22 @@
 
 	/* Give useful transfer information to the dialplan */
 	if (transferer->owner) {
-		struct ast_channel *peer = ast_bridged_channel(transferer->owner);
+		RAII_VAR(struct ast_channel *, peer, ast_channel_bridge_peer(transferer->owner), ast_channel_cleanup);
+
+		/*! pbx_builtin_setvar_helper will attempt to lock the channel. We need
+		 * to be sure it's already locked here so we don't deadlock.
+		 */
+		while (peer && ast_channel_trylock(peer)) {
+			sip_pvt_unlock(transferer);
+			do {
+				CHANNEL_DEADLOCK_AVOIDANCE(transferer->owner);
+			} while (sip_pvt_trylock(transferer));
+		}
+
 		if (peer) {
 			pbx_builtin_setvar_helper(peer, "SIPREFERRINGCONTEXT", transferer->context);
 			pbx_builtin_setvar_helper(peer, "SIPREFERREDBYHDR", p_referred_by);
+			ast_channel_unlock(peer);
 		}
 	}
 
@@ -26350,7 +26361,6 @@
 {
 	struct ast_channel *c=NULL;
 	int res;
-	struct ast_channel *bridged_to;
 	const char *required;
 
 	/* If we have an INCOMING invite that we haven't answered, terminate that transaction */
@@ -26371,7 +26381,7 @@
 	/* Get RTCP quality before end of call */
 	if (p->do_history || p->owner) {
 		char quality_buf[AST_MAX_USER_FIELD], *quality;
-		struct ast_channel *bridge = p->owner ? ast_bridged_channel(p->owner) : NULL;
+		RAII_VAR(struct ast_channel *, bridge, p->owner ? ast_channel_bridge_peer(p->owner) : NULL, ast_channel_cleanup);
 
 		/* We need to get the lock on bridge because ast_rtp_instance_set_stats_vars will attempt
 		 * to lock the bridge. This may get hairy...
@@ -26384,7 +26394,6 @@
 				usleep(1);
 				sip_pvt_lock(p);
 			} while (p->owner && ast_channel_trylock(p->owner));
-			bridge = p->owner ? ast_bridged_channel(p->owner) : NULL;
 		}
 
 
@@ -26448,7 +26457,7 @@
 		if (!res) {
 			c = p->owner;
 			if (c) {
-				bridged_to = ast_bridged_channel(c);
+				RAII_VAR(struct ast_channel *, bridged_to, ast_channel_bridge_peer(c), ast_channel_cleanup);
 				if (bridged_to) {
 					/* Don't actually hangup here... */
 					ast_queue_unhold(c);

Modified: team/mmichelson/bridged_channel/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/bridged_channel/channels/chan_skinny.c?view=diff&rev=395808&r1=395807&r2=395808
==============================================================================
--- team/mmichelson/bridged_channel/channels/chan_skinny.c (original)
+++ team/mmichelson/bridged_channel/channels/chan_skinny.c Tue Jul 30 16:22:28 2013
@@ -4356,10 +4356,12 @@
 				l->label);
 			if (verbose) {
 				AST_LIST_TRAVERSE(&l->sub, sub, list) {
+					RAII_VAR(struct ast_channel *, bridged, ast_channel_bridge_peer(sub->owner), ao2_cleanup);
+
 					ast_cli(fd, "  %s> %s to %s\n",
 						(sub == l->activesub?"Active  ":"Inactive"),
 						ast_channel_name(sub->owner),
-						(ast_bridged_channel(sub->owner)?ast_channel_name(ast_bridged_channel(sub->owner)):"")
+						bridged ? ast_channel_name(bridged) : ""
 					);
 				}
 			}
@@ -6410,10 +6412,13 @@
 		SKINNY_DEBUG(DEBUG_PACKET, 3, "Received STIMULUS_CALLPARK from %s, inst %d, callref %d\n",
 			d->name, instance, callreference);
 
-		if ((sub && sub->owner) && (ast_channel_state(sub->owner) ==  AST_STATE_UP)){
+		if ((sub && sub->owner) && (ast_channel_state(sub->owner) ==  AST_STATE_UP)) {
+			RAII_VAR(struct ast_channel *, bridged, NULL, ast_channel_cleanup);
+
 			c = sub->owner;
-			if (ast_bridged_channel(c)) {
-				if (!ast_masq_park_call(ast_bridged_channel(c), c, 0, &extout)) {
+			bridged = ast_channel_bridge_peer(c);
+			if (bridged) {
+				if (!ast_masq_park_call(bridged, c, 0, &extout)) {
 					snprintf(message, sizeof(message), "Call Parked at: %d", extout);
 					transmit_displaynotify(d, message, 10);
 				} else {
@@ -7148,9 +7153,12 @@
 			d->name, instance, callreference);
 
 		if ((sub && sub->owner) && (ast_channel_state(sub->owner) ==  AST_STATE_UP)){
+			RAII_VAR(struct ast_channel *, bridged, NULL, ast_channel_cleanup);
+
 			c = sub->owner;
-			if (ast_bridged_channel(c)) {
-				if (!ast_masq_park_call(ast_bridged_channel(c), c, 0, &extout)) {
+			bridged = ast_channel_bridge_peer(c);
+			if (bridged) {
+				if (!ast_masq_park_call(bridged, c, 0, &extout)) {
 					snprintf(message, sizeof(message), "Call Parked at: %d", extout);
 					transmit_displaynotify(d, message, 10);
 				} else {




More information about the asterisk-commits mailing list