[asterisk-commits] dlee: branch dlee/stable-id r378909 - /team/dlee/stable-id/main/channel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 10 11:05:38 CST 2013


Author: dlee
Date: Thu Jan 10 11:05:34 2013
New Revision: 378909

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378909
Log:
Made the uniqueid/name shuffle much clearer.

Modified:
    team/dlee/stable-id/main/channel.c

Modified: team/dlee/stable-id/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stable-id/main/channel.c?view=diff&rev=378909&r1=378908&r2=378909
==============================================================================
--- team/dlee/stable-id/main/channel.c (original)
+++ team/dlee/stable-id/main/channel.c Thu Jan 10 11:05:34 2013
@@ -6865,8 +6865,7 @@
 	struct ast_format rformat;
 	struct ast_format wformat;
 	struct ast_format tmp_format;
-	char newn[AST_CHANNEL_NAME];
-	char zombn[AST_CHANNEL_NAME];
+	char tmp_name[AST_CHANNEL_NAME];
 	const char *tmp_id;
 	char clone_sending_dtmf_digit;
 	struct timeval clone_sending_dtmf_tv;
@@ -6970,11 +6969,17 @@
 				<parameter name="Clone">
 					<para>The name of the channel whose information will be going into the Original channel.</para>
 				</parameter>
+				<parameter name="CloneUniqueid">
+					<para>The uniqueid of the channel whose information will be going into the Original channel.</para>
+				</parameter>
 				<parameter name="CloneState">
 					<para>The current state of the clone channel.</para>
 				</parameter>
 				<parameter name="Original">
 					<para>The name of the channel whose information will be replaced by the Clone channel's information.</para>
+				</parameter>
+				<parameter name="OriginalUniqueid">
+					<para>The uniqueid of the channel whose information will be replaced by the Clone channel's information.</para>
 				</parameter>
 				<parameter name="OriginalState">
 					<para>The current state of the original channel.</para>
@@ -6991,11 +6996,6 @@
 		"OriginalState: %s\r\n",
 		ast_channel_name(clonechan), ast_channel_uniqueid(clonechan), ast_state2str(ast_channel_state(clonechan)), ast_channel_name(original), ast_channel_uniqueid(original), ast_state2str(ast_channel_state(original)));
 
-	/* Swap uniqueid's of the channels */
-	tmp_id = ast_strdupa(ast_channel_uniqueid(clonechan));
-	ast_channel_uniqueid_set(clonechan, ast_channel_uniqueid(original));
-	ast_channel_uniqueid_set(original, tmp_id);
-
 	/*
 	 * Remember the original read/write formats.  We turn off any
 	 * translation on either one
@@ -7009,19 +7009,21 @@
 	clone_sending_dtmf_digit = ast_channel_sending_dtmf_digit(clonechan);
 	clone_sending_dtmf_tv = ast_channel_sending_dtmf_tv(clonechan);
 
-	/* Save the new name */
-	ast_copy_string(newn, ast_channel_name(clonechan), sizeof(newn));
-	/* Create the zombie name */
-	snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", ast_channel_name(original)); /* quick, hide the brains! */
-
-	/*
-	 * Shuffle names around on the channels, and do so in such a way that we only send
-	 * one rename event: original -> original<ZOMBIE>. The other renames are implementation
-	 * details of the masquerade, and shouldn't generate events.
+	/* Swap uniqueid's of the channels */
+	tmp_id = ast_strdupa(ast_channel_uniqueid(clonechan));
+	ast_channel_uniqueid_set(clonechan, ast_channel_uniqueid(original));
+	ast_channel_uniqueid_set(original, tmp_id);
+
+	/* Swap channel names. This uses ast_channel_name_set directly, so we
+	 * don't get any spurious rename events.
 	 */
+	ast_copy_string(tmp_name, ast_channel_name(clonechan), sizeof(tmp_name));
 	ast_channel_name_set(clonechan, ast_channel_name(original));
-	__ast_change_name_nolink(clonechan, zombn);
-	ast_channel_name_set(original, newn);
+	ast_channel_name_set(original, tmp_name);
+
+	/* Now zombify the clonechan. This gets a real rename event. */
+	snprintf(tmp_name, sizeof(tmp_name), "%s<ZOMBIE>", ast_channel_name(clonechan)); /* quick, hide the brains! */
+	__ast_change_name_nolink(clonechan, tmp_name);
 
 	/* share linked id's */
 	ast_channel_set_linkgroup(original, clonechan);




More information about the asterisk-commits mailing list