Workaround for deadlock condition seen on dual CPU machines running Mac OS X; cap the MD_PauseCPU timeout to 500ms so that we don't stall for longer than that on startup. This does not affect Mac OS 9 builds (which ignore the time parameter). Bug 99561. r=dagley, wtc. a=asa MOZILLA_0_9_8_BRANCH MOZILLA_0_9_8_RELEASE
authorsfraser%netscape.com
Thu, 31 Jan 2002 06:20:15 +0000
branchMOZILLA_0_9_8_BRANCH
changeset 2209 98bea58d599b
parent 2208 65ce3a7be17a
push idunknown
push userunknown
push dateunknown
reviewersdagley, wtc, asa
bugs99561
Workaround for deadlock condition seen on dual CPU machines running Mac OS X; cap the MD_PauseCPU timeout to 500ms so that we don't stall for longer than that on startup. This does not affect Mac OS 9 builds (which ignore the time parameter). Bug 99561. r=dagley, wtc. a=asa
pr/src/md/mac/macthr.c
--- a/pr/src/md/mac/macthr.c
+++ b/pr/src/md/mac/macthr.c
@@ -217,20 +217,31 @@ void _MD_StartInterrupts(void)
 void _MD_StopInterrupts(void)
 {
 	if (gTimeManagerTaskElem.tmAddr != NULL) {
 		RmvTime((QElemPtr)&gTimeManagerTaskElem);
 		gTimeManagerTaskElem.tmAddr = NULL;
 	}
 }
 
+
+#define MAX_PAUSE_TIMEOUT_MS    500
+
 void _MD_PauseCPU(PRIntervalTime timeout)
 {
     if (timeout != PR_INTERVAL_NO_WAIT)
     {
+        // There is a race condition entering the critical section
+        // in AsyncIOCompletion (and probably elsewhere) that can
+        // causes deadlock for the duration of this timeout. To
+        // work around this, use a max 500ms timeout for now.
+        // See bug 99561 for details.
+        if (PR_IntervalToMilliseconds(timeout) > MAX_PAUSE_TIMEOUT_MS)
+            timeout = PR_MillisecondsToInterval(MAX_PAUSE_TIMEOUT_MS);
+
         WaitOnIdleSemaphore(timeout);
         (void) _MD_IOInterrupt();
     }
 }
 
 
 //##############################################################################
 //##############################################################################