[asterisk-commits] mmichelson: branch mmichelson/atxfer_features r393129 - in /team/mmichelson/a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 28 10:46:14 CDT 2013


Author: mmichelson
Date: Fri Jun 28 10:46:03 2013
New Revision: 393129

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393129
Log:
Make further changes when merging bridges to ensure I do not try to kick a NULL bridge channel out.


Modified:
    team/mmichelson/atxfer_features/include/asterisk/bridging_private.h
    team/mmichelson/atxfer_features/main/bridging.c
    team/mmichelson/atxfer_features/main/bridging_basic.c

Modified: team/mmichelson/atxfer_features/include/asterisk/bridging_private.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/include/asterisk/bridging_private.h?view=diff&rev=393129&r1=393128&r2=393129
==============================================================================
--- team/mmichelson/atxfer_features/include/asterisk/bridging_private.h (original)
+++ team/mmichelson/atxfer_features/include/asterisk/bridging_private.h Fri Jun 28 10:46:03 2013
@@ -67,4 +67,18 @@
 void bridge_merge_do(struct ast_bridge *dst_bridge, struct ast_bridge *src_bridge,
 		struct ast_bridge_channel **kick_me, unsigned int num_kick);
 
+/*!
+ * \internal
+ * \brief Helper function to find a bridge channel given a channel.
+ *
+ * \param bridge What to search
+ * \param chan What to search for.
+ *
+ * \note On entry, bridge is already locked.
+ *
+ * \retval bridge_channel if channel is in the bridge.
+ * \retval NULL if not in bridge.
+ */
+struct ast_bridge_channel *find_bridge_channel(struct ast_bridge *bridge, struct ast_channel *chan);
+
 #endif /* _ASTERISK_PRIVATE_BRIDGING_H */

Modified: team/mmichelson/atxfer_features/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/main/bridging.c?view=diff&rev=393129&r1=393128&r2=393129
==============================================================================
--- team/mmichelson/atxfer_features/main/bridging.c (original)
+++ team/mmichelson/atxfer_features/main/bridging.c Fri Jun 28 10:46:03 2013
@@ -474,7 +474,7 @@
  * \retval bridge_channel if channel is in the bridge.
  * \retval NULL if not in bridge.
  */
-static struct ast_bridge_channel *find_bridge_channel(struct ast_bridge *bridge, struct ast_channel *chan)
+struct ast_bridge_channel *find_bridge_channel(struct ast_bridge *bridge, struct ast_channel *chan)
 {
 	struct ast_bridge_channel *bridge_channel;
 

Modified: team/mmichelson/atxfer_features/main/bridging_basic.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/main/bridging_basic.c?view=diff&rev=393129&r1=393128&r2=393129
==============================================================================
--- team/mmichelson/atxfer_features/main/bridging_basic.c (original)
+++ team/mmichelson/atxfer_features/main/bridging_basic.c Fri Jun 28 10:46:03 2013
@@ -601,40 +601,34 @@
 	return res;
 }
 
-static void bridge_merge(struct ast_bridge *dest, struct ast_bridge *src, struct ast_channel **kick_me, unsigned int num_kick)
-{
-	struct ast_bridge_channel **kick_bridge_channels = num_kick ?
-		ast_alloca(num_kick * sizeof(*kick_bridge_channels)) : NULL;
+static void bridge_merge(struct ast_bridge *dest, struct ast_bridge *src, struct ast_channel **kick_channels, unsigned int num_channels)
+{
+	struct ast_bridge_channel **kick_bridge_channels = num_channels ?
+		ast_alloca(num_channels * sizeof(*kick_bridge_channels)) : NULL;
 	int i;
-	int actual_num_kick = 0;
+	int num_bridge_channels = 0;
 
 	ast_bridge_lock_both(dest, src);
 
-	for (i = 0; i < num_kick; ++i) {
-		struct ast_bridge_channel *kick_channel;
-
-		ast_channel_lock(kick_me[i]);
-		kick_channel = ast_channel_get_bridge_channel(kick_me[i]);
-		ast_channel_unlock(kick_me[i]);
+	for (i = 0; i < num_channels; ++i) {
+		struct ast_bridge_channel *kick_bridge_channel;
+
+		kick_bridge_channel = find_bridge_channel(src, kick_channels[i]);
 
 		/* It's possible (and fine) for the bridge channel to be NULL at this point if the
 		 * channel has hung up already. If that happens, we can just remove it from the list
 		 * of bridge channels to kick from the bridge
 		 */
-		if (!kick_channel) {
+		if (!kick_bridge_channel) {
 			continue;
 		}
 
-		kick_bridge_channels[actual_num_kick++] = kick_channel;
-	}
-
-	bridge_merge_do(dest, src, kick_bridge_channels, num_kick);
+		kick_bridge_channels[num_bridge_channels++] = kick_bridge_channel;
+	}
+
+	bridge_merge_do(dest, src, kick_bridge_channels, num_bridge_channels);
 	ast_bridge_unlock(dest);
 	ast_bridge_unlock(src);
-
-	for (i = 0; i < actual_num_kick; ++i) {
-		ao2_cleanup(kick_bridge_channels[i]);
-	}
 }
 
 /*!




More information about the asterisk-commits mailing list