[asterisk-commits] rmudgett: branch group/bridge_construction r386482 - in /team/group/bridge_co...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 24 21:30:30 CDT 2013


Author: rmudgett
Date: Wed Apr 24 21:30:27 2013
New Revision: 386482

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386482
Log:
* Add ast_bridge_lock_both() macro.

* Remove some unnecessary bridge->merge_inhibit changes.

Modified:
    team/group/bridge_construction/include/asterisk/bridging.h
    team/group/bridge_construction/main/bridging.c

Modified: team/group/bridge_construction/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/include/asterisk/bridging.h?view=diff&rev=386482&r1=386481&r2=386482
==============================================================================
--- team/group/bridge_construction/include/asterisk/bridging.h (original)
+++ team/group/bridge_construction/include/asterisk/bridging.h Wed Apr 24 21:30:27 2013
@@ -546,6 +546,19 @@
 	__ao2_unlock(bridge, file, function, line, var);
 }
 
+/*! \brief Lock two bridges. */
+#define ast_bridge_lock_both(bridge1, bridge2)		\
+	do {											\
+		for (;;) {									\
+			ast_bridge_lock(bridge1);				\
+			if (!ast_bridge_trylock(bridge2)) {		\
+				break;								\
+			}										\
+			ast_bridge_unlock(bridge1);				\
+			sched_yield();							\
+		}											\
+	} while (0)
+
 /*!
  * \brief See if it is possible to create a bridge
  *

Modified: team/group/bridge_construction/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/main/bridging.c?view=diff&rev=386482&r1=386481&r2=386482
==============================================================================
--- team/group/bridge_construction/main/bridging.c (original)
+++ team/group/bridge_construction/main/bridging.c Wed Apr 24 21:30:27 2013
@@ -3100,15 +3100,7 @@
 {
 	int res = -1;
 
-	/* Deadlock avoidance. */
-	for (;;) {
-		ast_bridge_lock(dst_bridge);
-		if (!ast_bridge_trylock(src_bridge)) {
-			break;
-		}
-		ast_bridge_unlock(dst_bridge);
-		sched_yield();
-	}
+	ast_bridge_lock_both(dst_bridge, src_bridge);
 
 	if (dst_bridge->dissolved || src_bridge->dissolved) {
 		ast_debug(1, "Can't merge bridge %s into bridge %s, one or both bridges are dissolved.\n",
@@ -3125,11 +3117,7 @@
 		ast_debug(1, "Can't merge bridge %s into bridge %s, multimix is needed and it cannot be acquired.\n",
 			src_bridge->uniqueid, dst_bridge->uniqueid);
 	} else {
-		++dst_bridge->inhibit_merge;
-		++src_bridge->inhibit_merge;
 		bridge_merge_do(dst_bridge, src_bridge, NULL, 0);
-		--src_bridge->inhibit_merge;
-		--dst_bridge->inhibit_merge;
 		res = 0;
 	}
 




More information about the asterisk-commits mailing list