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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 5 15:09:16 CDT 2013


Author: mmichelson
Date: Wed Jun  5 15:09:13 2013
New Revision: 390568

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390568
Log:
Take care of removing bridge hooks on personality change.

Removing hooks that have certain flags is now a public function.


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

Modified: team/mmichelson/atxfer_features/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/include/asterisk/bridging.h?view=diff&rev=390568&r1=390567&r2=390568
==============================================================================
--- team/mmichelson/atxfer_features/include/asterisk/bridging.h (original)
+++ team/mmichelson/atxfer_features/include/asterisk/bridging.h Wed Jun  5 15:09:13 2013
@@ -1654,6 +1654,16 @@
  */
 struct ast_channel *ast_bridge_peer(struct ast_bridge *bridge, struct ast_channel *chan);
 
+/*!
+ * \brief Remove marked bridge channel feature hooks.
+ * \since 12.0.0
+ *
+ * \param features Bridge features structure
+ * \param flags Determinator for whether hook is removed.
+ *
+ * \return Nothing
+ */
+void ast_bridge_features_remove(struct ast_bridge_features *features, enum ast_bridge_hook_remove_flags flags);
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/mmichelson/atxfer_features/include/asterisk/bridging_features.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/include/asterisk/bridging_features.h?view=diff&rev=390568&r1=390567&r2=390568
==============================================================================
--- team/mmichelson/atxfer_features/include/asterisk/bridging_features.h (original)
+++ team/mmichelson/atxfer_features/include/asterisk/bridging_features.h Wed Jun  5 15:09:13 2013
@@ -183,6 +183,8 @@
 enum ast_bridge_hook_remove_flags {
 	/*! The hook is removed when the channel is pulled from the bridge. */
 	AST_BRIDGE_HOOK_REMOVE_ON_PULL,
+	/*! The hook is removed when the bridge's personality changes. */
+	AST_BRIDGE_HOOK_REMOVE_ON_PERSONALITY_CHANGE,
 };
 
 /* BUGBUG Need to be able to selectively remove DTMF, hangup, and interval hooks. */

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=390568&r1=390567&r2=390568
==============================================================================
--- team/mmichelson/atxfer_features/main/bridging.c (original)
+++ team/mmichelson/atxfer_features/main/bridging.c Wed Jun  5 15:09:13 2013
@@ -76,7 +76,6 @@
 
 static void cleanup_video_mode(struct ast_bridge *bridge);
 static int bridge_make_compatible(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
-static void bridge_features_remove(struct ast_bridge_features *features, enum ast_bridge_hook_remove_flags flags);
 
 /*! Default DTMF keys for built in features */
 static char builtin_features_dtmf[AST_BRIDGE_BUILTIN_END][MAXIMUM_DTMF_FEATURE_STRING];
@@ -1399,7 +1398,7 @@
  */
 static void bridge_base_pull(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel)
 {
-	bridge_features_remove(bridge_channel->features, AST_BRIDGE_HOOK_REMOVE_ON_PULL);
+	ast_bridge_features_remove(bridge_channel->features, AST_BRIDGE_HOOK_REMOVE_ON_PULL);
 }
 
 /*!
@@ -4697,17 +4696,7 @@
 	ast_heap_unlock(hooks);
 }
 
-/*!
- * \internal
- * \brief Remove marked bridge channel feature hooks.
- * \since 12.0.0
- *
- * \param features Bridge features structure
- * \param flags Determinator for whether hook is removed.
- *
- * \return Nothing
- */
-static void bridge_features_remove(struct ast_bridge_features *features, enum ast_bridge_hook_remove_flags flags)
+void ast_bridge_features_remove(struct ast_bridge_features *features, enum ast_bridge_hook_remove_flags flags)
 {
 	hooks_remove_container(features->dtmf_hooks, flags);
 	hooks_remove_container(features->hangup_hooks, flags);

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=390568&r1=390567&r2=390568
==============================================================================
--- team/mmichelson/atxfer_features/main/bridging_basic.c (original)
+++ team/mmichelson/atxfer_features/main/bridging_basic.c Wed Jun  5 15:09:13 2013
@@ -193,42 +193,13 @@
 	return bridge;
 }
 
-static int remove_hook(void *obj, void *arg, int flags)
-{
-	struct ast_bridge_hook *hook = obj;
-
-	if (hook->remove_on_personality_change) {
-		return CMP_MATCH;
-	}
-
-	return 0;
-}
-
-/* XXX This seems like something that should be handled in the core since otherwise
- * this has to be done in every bridge subclass that implements personalities
- */
 static void remove_hooks_on_personality_change(struct ast_bridge *bridge)
 {
 	struct ast_bridge_channel *iter;
-	int flags = OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE;
 
 	AST_LIST_TRAVERSE(&bridge->channels, iter, entry) {
 		SCOPED_LOCK(lock, iter, ast_bridge_channel_lock, ast_bridge_channel_unlock);
-
-		ao2_callback(iter->features->dtmf_hooks, flags, remove_hook, NULL);
-		ao2_callback(iter->features->hangup_hooks, flags, remove_hook, NULL);
-		ao2_callback(iter->features->join_hooks, flags, remove_hook, NULL);
-		ao2_callback(iter->features->leave_hooks, flags, remove_hook, NULL);
-		/* XXX Come back for interval hooks.
-		 *
-		 * Since it's a heap instead of an ao2_conatainer, I'll need to pop
-		 * each element off the heap, inspect it and then either discard the hook
-		 * or put it in a local heap. Once finished, I can set the interval hooks
-		 * to point to the local heap and destroy the old one.
-		 *
-		 * Also need to check lock order to see if wrlocking the heap will clash
-		 * with the already-held bridge and bridge channel locks
-		 */
+		ast_bridge_features_remove(iter->features, AST_BRIDGE_HOOK_REMOVE_ON_PERSONALITY_CHANGE);
 	}
 }
 
@@ -238,8 +209,10 @@
 
 	ast_assert(bridge->v_table == &ast_bridge_base_v_table);
 
-	bridge->personality = &bridge_atxfer_personality;
-	remove_hooks_on_personality_change(bridge);
+	if (bridge->personality != &bridge_atxfer_personality) {
+		bridge->personality = &bridge_atxfer_personality;
+		remove_hooks_on_personality_change(bridge);
+	}
 }
 
 void ast_bridge_basic_change_personality_normal(struct ast_bridge *bridge)
@@ -248,8 +221,10 @@
 
 	ast_assert(bridge->v_table == &ast_bridge_base_v_table);
 
-	bridge->personality = &bridge_normal_personality;
-	remove_hooks_on_personality_change(bridge);
+	if (bridge->personality != &bridge_normal_personality) {
+		bridge->personality = &bridge_normal_personality;
+		remove_hooks_on_personality_change(bridge);
+	}
 }
 
 /*!




More information about the asterisk-commits mailing list