[asterisk-commits] dhubbard: branch 1.4 r84274 - in /branches/1.4: channels/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Oct 1 16:25:38 CDT 2007


Author: dhubbard
Date: Mon Oct  1 16:25:37 2007
New Revision: 84274

URL: http://svn.digium.com/view/asterisk?view=rev&rev=84274
Log:
moved get_base_channel() code from action_redirect to ast_channel_masquerade() for issue 7706 and BE-160

Modified:
    branches/1.4/channels/chan_agent.c
    branches/1.4/main/channel.c
    branches/1.4/main/manager.c

Modified: branches/1.4/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_agent.c?view=diff&rev=84274&r1=84273&r2=84274
==============================================================================
--- branches/1.4/channels/chan_agent.c (original)
+++ branches/1.4/channels/chan_agent.c Mon Oct  1 16:25:37 2007
@@ -730,17 +730,20 @@
 	pbx_builtin_setvar_helper(NULL, buf, agent);
 }
 
+/*! \brief return the channel or base channel if one exists.  This function assumes the channel it is called on is already locked */
 struct ast_channel* agent_get_base_channel(struct ast_channel *chan)
 {
 	struct agent_pvt *p = NULL;
-	struct ast_channel *base = NULL;
-	
+	struct ast_channel *base = chan;
+
+	/* chan is locked by the calling function */
 	if (!chan || !chan->tech_pvt) {
 		ast_log(LOG_ERROR, "whoa, you need a channel (0x%ld) with a tech_pvt (0x%ld) to get a base channel.\n", (long)chan, (chan)?(long)chan->tech_pvt:(long)NULL);
-	} else {
-		p = chan->tech_pvt;
+		return NULL;
+	}
+	p = chan->tech_pvt;
+	if (p->chan) 
 		base = p->chan;
-	}
 	return base;
 }
 

Modified: branches/1.4/main/channel.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/channel.c?view=diff&rev=84274&r1=84273&r2=84274
==============================================================================
--- branches/1.4/main/channel.c (original)
+++ branches/1.4/main/channel.c Mon Oct  1 16:25:37 2007
@@ -3410,7 +3410,7 @@
 int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone)
 {
 	int res = -1;
-	struct ast_channel *final_orig, *final_clone;
+	struct ast_channel *final_orig, *final_clone, *base;
 
 retrymasq:
 	final_orig = original;
@@ -3430,6 +3430,10 @@
 
 	if (clone->_bridge && (clone->_bridge != ast_bridged_channel(clone)) && (clone->_bridge->_bridge != clone))
 		final_clone = clone->_bridge;
+	
+	if (final_clone->tech->get_base_channel && (base = final_clone->tech->get_base_channel(final_clone))) {
+		final_clone = base;
+	}
 
 	if ((final_orig != original) || (final_clone != clone)) {
 		/* Lots and lots of deadlock avoidance.  The main one we're competing with

Modified: branches/1.4/main/manager.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/manager.c?view=diff&rev=84274&r1=84273&r2=84274
==============================================================================
--- branches/1.4/main/manager.c (original)
+++ branches/1.4/main/manager.c Mon Oct  1 16:25:37 2007
@@ -1550,7 +1550,7 @@
 	const char *exten = astman_get_header(m, "Exten");
 	const char *context = astman_get_header(m, "Context");
 	const char *priority = astman_get_header(m, "Priority");
-	struct ast_channel *base, *chan, *chan2 = NULL;
+	struct ast_channel *chan, *chan2 = NULL;
 	int pi = 0;
 	int res;
 
@@ -1572,14 +1572,6 @@
 		astman_send_error(s, m, buf);
 		return 0;
 	}
-	if (chan->tech->get_base_channel) {
-		base = chan->tech->get_base_channel(chan);
-		if (base) {
-			ast_mutex_unlock(&chan->lock);
-			chan = base;
-			ast_mutex_lock(&chan->lock);
-		}
-	}
 	if (ast_check_hangup(chan)) {
 		astman_send_error(s, m, "Redirect failed, channel not up.\n");
 		ast_channel_unlock(chan);
@@ -1592,14 +1584,6 @@
 		ast_channel_unlock(chan);
 		ast_channel_unlock(chan2);
 		return 0;
-	}
-	if (chan2 && chan2->tech->get_base_channel) {
-		base = chan2->tech->get_base_channel(chan2);
-		if (base) {
-			ast_mutex_unlock(&chan2->lock);
-			chan2 = base;
-			ast_mutex_lock(&chan2->lock);
-		}
 	}
 	res = ast_async_goto(chan, context, exten, pi);
 	if (!res) {




More information about the asterisk-commits mailing list