[svn-commits] bmd: branch group/newcdr r117252 - /team/group/newcdr/main/channel.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon May 19 17:42:41 CDT 2008


Author: bmd
Date: Mon May 19 17:42:41 2008
New Revision: 117252

URL: http://svn.digium.com/view/asterisk?view=rev&rev=117252
Log:
Make linkedid much more infectous.  This fixes a problem with linkedid not transferring to bridged channels when an assisted xfer occurs.  Now when two sets of bridged channels are sent through a masq (hanging up the two owned by the transferer), the linkedid of the two remaining bridged channels is the oldest one of the four.

Modified:
    team/group/newcdr/main/channel.c

Modified: team/group/newcdr/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/main/channel.c?view=diff&rev=117252&r1=117251&r2=117252
==============================================================================
--- team/group/newcdr/main/channel.c (original)
+++ team/group/newcdr/main/channel.c Mon May 19 17:42:41 2008
@@ -3756,30 +3756,47 @@
 	}
 }
 
+/* return the oldest of two uniqueids */
+#define OLDEST(a,b) (ast_strlen_zero(a) ? b : (ast_strlen_zero(b) ? a : (strcmp(a, b) < 0 ? a : b)))
+
 /*!
   \brief Propagate the linked id from one channel to the other
 
 */
 void ast_channel_set_linkgroup(struct ast_channel *chan, struct ast_channel *peer)
 {
-	if (ast_strlen_zero(chan->linkedid) && ast_strlen_zero(peer->linkedid)) {
-		ast_string_field_set(chan, linkedid, chan->uniqueid);
-		ast_string_field_set(peer, linkedid, chan->uniqueid);
-	} else if (!ast_strlen_zero(chan->linkedid) && ast_strlen_zero(peer->linkedid)) {
-		ast_string_field_set(peer, linkedid, chan->linkedid);
-	} else if (ast_strlen_zero(chan->linkedid) && !ast_strlen_zero(peer->linkedid)) {
-		ast_string_field_set(chan, linkedid, peer->linkedid);
-	} else {
-		int x = strcmp(chan->linkedid,peer->linkedid);
-		ast_log(LOG_WARNING,"linkid clash between (chan)%s and (peer) %s.\n",
-				chan->linkedid, peer->linkedid); /* smallest wins! */
-		if (x < 0)
-			ast_string_field_set(peer, linkedid, chan->linkedid); /* let the chan take precedence, then */
-		else if (x > 0)
-			ast_string_field_set(chan, linkedid, peer->linkedid); /* let the peer take precedence, then */
-	}
-}
-
+	const char* linkedid=NULL;
+	struct ast_channel *bridged;
+
+	linkedid = OLDEST(chan->linkedid, peer->linkedid);
+	linkedid = OLDEST(linkedid, chan->uniqueid);
+	linkedid = OLDEST(linkedid, peer->uniqueid);
+	if (chan->_bridge) {
+		bridged = ast_bridged_channel(chan);
+		linkedid = OLDEST(linkedid, bridged->linkedid);
+		linkedid = OLDEST(linkedid, bridged->uniqueid);
+	}
+	if (peer->_bridge) {
+		bridged = ast_bridged_channel(peer);
+		linkedid = OLDEST(linkedid, bridged->linkedid);
+		linkedid = OLDEST(linkedid, bridged->uniqueid);
+	}
+
+	/* just in case setting a stringfield to itself causes problems */
+	linkedid = ast_strdupa(linkedid);
+
+	ast_string_field_set(chan, linkedid, linkedid);
+	ast_string_field_set(peer, linkedid, linkedid);
+	if (chan->_bridge) {
+		bridged = ast_bridged_channel(chan);
+		ast_string_field_set(bridged, linkedid, linkedid);
+	}
+	if (peer->_bridge) {
+		bridged = ast_bridged_channel(peer);
+		ast_string_field_set(bridged, linkedid, linkedid);
+	}
+}
+  
 /* copy accountcode and peeraccount across during a link */
 static void ast_set_owners_and_peers(struct ast_channel *chan1,
 									 struct ast_channel *chan2)




More information about the svn-commits mailing list