[asterisk-commits] mmichelson: branch mmichelson/transfer r386408 - /team/mmichelson/transfer/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 23 18:32:52 CDT 2013


Author: mmichelson
Date: Tue Apr 23 18:32:49 2013
New Revision: 386408

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386408
Log:
Use the ast_bridge_peers() function to get the transferee.

This probably should be done at a different time since the current
construct counts the channels in the bridge, then unlocks the bridge
and then gets the channels in the bridge. There exists the opportunity
for an unwanted third party to join the bridge during that gap.

Currently, an attempt to use the BlindTransfer manager action results
in a crash.


Modified:
    team/mmichelson/transfer/main/bridging.c

Modified: team/mmichelson/transfer/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/transfer/main/bridging.c?view=diff&rev=386408&r1=386407&r2=386408
==============================================================================
--- team/mmichelson/transfer/main/bridging.c (original)
+++ team/mmichelson/transfer/main/bridging.c Tue Apr 23 18:32:49 2013
@@ -4293,6 +4293,8 @@
 		struct ast_channel *transferer, const char *exten, const char *context)
 {
 	RAII_VAR(struct ast_bridge_channel *, transferer_bridge_channel, NULL, ao2_cleanup);
+	RAII_VAR(struct ao2_container *, channels, NULL, ao2_cleanup);
+	struct ao2_iterator channel_iter;
 	struct blind_transfer_data blind_data;
 	struct ast_channel *transferee;
 
@@ -4304,19 +4306,27 @@
 				ast_channel_name(transferer));
 		return AST_BRIDGE_TRANSFER_FAIL;
 	}
-	ao2_ref(transferer_bridge_channel, +1);
-	transferee = ast_bridged_channel(transferer);
-	if (!transferee) {
-		ast_channel_unlock(transferer);
-		ast_log(LOG_NOTICE, "Failed to get transferee channel\n");
-		return AST_BRIDGE_TRANSFER_FAIL;
-	}
-	ast_copy_string(blind_data.transferee_name, ast_channel_name(transferee),
-			sizeof(blind_data.transferee_name));
 	ast_copy_string(blind_data.transferer_name, ast_channel_name(transferer),
 			sizeof(blind_data.transferer_name));
 	ast_channel_unlock(transferer);
 
+	channels = ast_bridge_peers(bridge);
+
+	if (!channels) {
+		return AST_BRIDGE_TRANSFER_FAIL;
+	}
+
+	for (channel_iter = ao2_iterator_init(channels, 0);
+			(transferee = ao2_iterator_next(&channel_iter));
+			ao2_cleanup(transferee)) {
+		if (transferee != transferer) {
+			break;
+		}
+	}
+	ao2_iterator_destroy(&channel_iter);
+
+	ast_copy_string(blind_data.transferee_name, ast_channel_name(transferee),
+			sizeof(blind_data.transferee_name));
 	ast_copy_string(blind_data.exten, exten, sizeof(blind_data.exten));
 	ast_copy_string(blind_data.context, context, sizeof(blind_data.context));
 




More information about the asterisk-commits mailing list