[asterisk-commits] irroot: branch irroot/distrotech-customers r318993 - /team/irroot/distrotech-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat May 14 11:27:48 CDT 2011


Author: irroot
Date: Sat May 14 11:27:44 2011
New Revision: 318993

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=318993
Log:

Some avoidence added fro various deadlocks encounted


Modified:
    team/irroot/distrotech-customers/main/channel.c
    team/irroot/distrotech-customers/main/pbx.c

Modified: team/irroot/distrotech-customers/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers/main/channel.c?view=diff&rev=318993&r1=318992&r2=318993
==============================================================================
--- team/irroot/distrotech-customers/main/channel.c (original)
+++ team/irroot/distrotech-customers/main/channel.c Sat May 14 11:27:44 2011
@@ -6245,8 +6245,12 @@
 	 */
 	ao2_lock(channels);
 
-	/* lock the original channel to determine if the masquerade is require or not */
-	ast_channel_lock(original);
+	/* lock the original channel with deadlock avoidance to determine if the masquerade is require or not */
+	while (ast_channel_trylock(original)) {
+		ao2_unlock(channels);
+		usleep(1);
+		ao2_lock(channels);
+	}
 
 	/* This checks to see if the masquerade has already happened or not.  There is a
 	 * race condition that exists for this function. Since all pvt and channel locks

Modified: team/irroot/distrotech-customers/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers/main/pbx.c?view=diff&rev=318993&r1=318992&r2=318993
==============================================================================
--- team/irroot/distrotech-customers/main/pbx.c (original)
+++ team/irroot/distrotech-customers/main/pbx.c Sat May 14 11:27:44 2011
@@ -4284,7 +4284,11 @@
 		/* Device state changed since last check - notify the watchers */
 
 		ao2_lock(hints);
-		ao2_lock(hint);
+		while (ao2_trylock(hint)) {
+			ao2_unlock(hints);
+			usleep(1);
+			ao2_lock(hints);
+		}
 
 		if (hint->exten == NULL) {
 			/* the extension has been destroyed */
@@ -7112,7 +7116,11 @@
 	}
 	ast_hashtab_end_traversal(iter);
 
-	ao2_lock(hints);
+	while (ao2_trylock(hints)) {
+		ast_unlock_contexts();
+		usleep(1);
+		ast_rdlock_contexts();
+	}
 	writelocktime = ast_tvnow();
 
 	/* preserve all watchers for hints */




More information about the asterisk-commits mailing list