[asterisk-commits] russell: branch 1.4 r84783 - /branches/1.4/channels/chan_zap.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Oct 5 11:44:21 CDT 2007


Author: russell
Date: Fri Oct  5 11:44:21 2007
New Revision: 84783

URL: http://svn.digium.com/view/asterisk?view=rev&rev=84783
Log:
Do deadlock avoidance in a couple more places.  You can't lock two channels
at the same time without doing extra work to make sure it succeeds.
(closes issue #10895, patch by me)

Modified:
    branches/1.4/channels/chan_zap.c

Modified: branches/1.4/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_zap.c?view=diff&rev=84783&r1=84782&r2=84783
==============================================================================
--- branches/1.4/channels/chan_zap.c (original)
+++ branches/1.4/channels/chan_zap.c Fri Oct  5 11:44:21 2007
@@ -3167,7 +3167,11 @@
 		return AST_BRIDGE_FAILED_NOWARN;
 
 	ast_mutex_lock(&c0->lock);
-	ast_mutex_lock(&c1->lock);
+	while (ast_mutex_trylock(&c1->lock)) {
+		ast_mutex_unlock(&c0->lock);
+		usleep(1);
+		ast_mutex_lock(&c0->lock);
+	}
 
 	p0 = c0->tech_pvt;
 	p1 = c1->tech_pvt;
@@ -3335,7 +3339,12 @@
 		/* Here's our main loop...  Start by locking things, looking for private parts, 
 		   and then balking if anything is wrong */
 		ast_mutex_lock(&c0->lock);
-		ast_mutex_lock(&c1->lock);
+		while (ast_mutex_trylock(&c1->lock)) {
+			ast_mutex_unlock(&c0->lock);
+			usleep(1);
+			ast_mutex_lock(&c0->lock);
+		}
+
 		p0 = c0->tech_pvt;
 		p1 = c1->tech_pvt;
 




More information about the asterisk-commits mailing list