[asterisk-commits] file: branch 1.2 r42452 - /branches/1.2/channel.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Sep 8 11:50:43 MST 2006


Author: file
Date: Fri Sep  8 13:50:43 2006
New Revision: 42452

URL: http://svn.digium.com/view/asterisk?rev=42452&view=rev
Log:
Swap spies during masquerading

Modified:
    branches/1.2/channel.c

Modified: branches/1.2/channel.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channel.c?rev=42452&r1=42451&r2=42452&view=diff
==============================================================================
--- branches/1.2/channel.c (original)
+++ branches/1.2/channel.c Fri Sep  8 13:50:43 2006
@@ -2948,6 +2948,8 @@
 	void *t_pvt;
 	struct ast_callerid tmpcid;
 	struct ast_channel *clone = original->masq;
+	struct ast_channel_spy_list *spy_list;
+	struct ast_channel_spy *spy = NULL;
 	int rformat = original->readformat;
 	int wformat = original->writeformat;
 	char newn[100];
@@ -3024,6 +3026,27 @@
 	x = original->rawwriteformat;
 	original->rawwriteformat = clone->rawwriteformat;
 	clone->rawwriteformat = x;
+
+	/* Swap the spies */
+	spy_list = original->spies;
+	original->spies = clone->spies;
+	clone->spies = spy_list;
+
+	/* Update channel on respective spy lists if present */
+	if (original->spies) {
+		AST_LIST_TRAVERSE(&original->spies->list, spy, list) {
+			ast_mutex_lock(&spy->lock);
+			spy->chan = original;
+			ast_mutex_unlock(&spy->lock);
+		}
+	}
+	if (clone->spies) {
+		AST_LIST_TRAVERSE(&clone->spies->list, spy, list) {
+			ast_mutex_lock(&spy->lock);
+			spy->chan = clone;
+			ast_mutex_unlock(&spy->lock);
+		}
+	}
 
 	/* Save any pending frames on both sides.  Start by counting
 	 * how many we're going to need... */



More information about the asterisk-commits mailing list