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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 24 15:26:47 CDT 2013


Author: mmichelson
Date: Wed Apr 24 15:26:43 2013
New Revision: 386456

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386456
Log:
Cleanup a bit more and add doxygen.


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=386456&r1=386455&r2=386456
==============================================================================
--- team/mmichelson/transfer/main/bridging.c (original)
+++ team/mmichelson/transfer/main/bridging.c Wed Apr 24 15:26:43 2013
@@ -4291,6 +4291,20 @@
 	return AST_BRIDGE_TRANSFER_SUCCESS;
 }
 
+/*!
+ * \internal
+ * \brief Get the transferee channel
+ *
+ * This is only applicable to cases where a transfer is occurring on a
+ * two-party bridge. The channels container passed in is expected to only
+ * contain two channels, the transferer and the transferee. The transferer
+ * channel is passed in as a parameter to ensure we don't return it as
+ * the transferee channel.
+ *
+ * \param channels A two-channel container containing the transferer and transferee
+ * \param transferer The party that is transfering the call
+ * \return The party that is being transferred
+ */
 static struct ast_channel *get_transferee(struct ao2_container *channels, struct ast_channel *transferer)
 {
 	struct ao2_iterator channel_iter;
@@ -4308,17 +4322,26 @@
 	return transferee;
 }
 
-static int queue_blind_transfer_bridge_action(struct ao2_container *channels,
-		struct ast_channel *transferer, const char *exten, const char *context)
+/*!
+ * \internal
+ * \brief Queue a blind transfer action on a transferee bridge channel
+ *
+ * This is only relevant for when a blind transfer is performed on a two-party
+ * bridge. The transferee's bridge channel will have a blind transfer bridge
+ * action queued onto it, resulting in the party being redirected to a new
+ * destination
+ *
+ * \param transferee The channel to have the action queued on
+ * \param exten The destination extension for the transferee
+ * \param context The destination context for the transferee
+ * \retval 0 Successfully queued the action
+ * \retval non-zero Failed to queue the action
+ */
+static int queue_blind_transfer_bridge_action(struct ast_channel *transferee,
+		const char *exten, const char *context)
 {
 	RAII_VAR(struct ast_bridge_channel *, transferee_bridge_channel, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_channel *, transferee, NULL, ao2_cleanup);
 	struct blind_transfer_data blind_data;
-
-	transferee = get_transferee(channels, transferer);
-	if (!transferee) {
-		return -1;
-	}
 
 	ast_channel_lock(transferee);
 	transferee_bridge_channel = ast_channel_internal_bridge_channel(transferee);
@@ -4340,34 +4363,34 @@
 {
 	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
 	RAII_VAR(struct ao2_container *, channels, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_channel *, transferee, NULL, ao2_cleanup);
 	int do_bridge_transfer;
 	int transfer_prohibited;
 
-	ast_channel_lock(transferer);
-	bridge = ast_channel_internal_bridge(transferer);
-	if (!bridge) {
-		ast_channel_unlock(transferer);
-		return AST_BRIDGE_TRANSFER_INVALID;
-	}
-	ao2_ref(bridge, +1);
-	ast_channel_unlock(transferer);
-
-	ast_bridge_lock(bridge);
-	transfer_prohibited = ast_test_flag(&bridge->feature_flags,
-			AST_BRIDGE_FLAG_TRANSFER_PROHIBITED);
-	channels = ast_bridge_peers_nolock(bridge);
-	if (!channels) {
-		ast_bridge_unlock(bridge);
-		return AST_BRIDGE_TRANSFER_FAIL;
-	}
-	if (ao2_container_count(channels) <= 1) {
-		ast_bridge_unlock(bridge);
-		return AST_BRIDGE_TRANSFER_INVALID;
-	}
-	do_bridge_transfer = ast_test_flag(&bridge->feature_flags, 
-			AST_BRIDGE_FLAG_TRANSFER_BRIDGE_ONLY) ||
-			ao2_container_count(channels) > 2;
-	ast_bridge_unlock(bridge);
+	{
+		SCOPED_LOCK(lock, transferer, ast_channel_lock, ast_channel_unlock);
+		bridge = ast_channel_internal_bridge(transferer);
+		if (!bridge) {
+			return AST_BRIDGE_TRANSFER_INVALID;
+		}
+		ao2_ref(bridge, +1);
+	}
+
+	{
+		SCOPED_LOCK(lock, bridge, ast_bridge_lock, ast_bridge_unlock);
+		channels = ast_bridge_peers_nolock(bridge);
+		if (!channels) {
+			return AST_BRIDGE_TRANSFER_FAIL;
+		}
+		if (ao2_container_count(channels) <= 1) {
+			return AST_BRIDGE_TRANSFER_INVALID;
+		}
+		transfer_prohibited = ast_test_flag(&bridge->feature_flags,
+				AST_BRIDGE_FLAG_TRANSFER_PROHIBITED);
+		do_bridge_transfer = ast_test_flag(&bridge->feature_flags, 
+				AST_BRIDGE_FLAG_TRANSFER_BRIDGE_ONLY) ||
+				ao2_container_count(channels) > 2;
+	}
 
 	if (transfer_prohibited) {
 		return AST_BRIDGE_TRANSFER_NOT_PERMITTED;
@@ -4377,7 +4400,14 @@
 		return local_channel_swap_transfer(transferer, bridge, exten, context);
 	}
 
-	if (queue_blind_transfer_bridge_action(channels, transferer, exten, context)) {
+	/* Reaching this portion means that we're dealing with a two-party bridge */
+
+	transferee = get_transferee(channels, transferer);
+	if (!transferee) {
+		return AST_BRIDGE_TRANSFER_FAIL;
+	}
+
+	if (queue_blind_transfer_bridge_action(transferee, exten, context)) {
 		return AST_BRIDGE_TRANSFER_FAIL;
 	}
 




More information about the asterisk-commits mailing list