Workaround fix for a stall on launch on dual CPU OS X machines, that is caused by a race condition entering the critical section. Bug 99561. r=wtc, a=dbaron NSPRPUB_PRE_4_2_CLIENT_BRANCH SYD_TEST_03052002_BASE
authorsfraser%netscape.com
Tue, 05 Mar 2002 00:51:52 +0000
branchNSPRPUB_PRE_4_2_CLIENT_BRANCH
changeset 2282 588ccb8175dc4d6fb3202db48bfc65e8d1af56bd
parent 2278 bcd6334afeca36d2e603ee726a51f6bdf7c6af69
child 2283 84c50a43aa5e695043bac87c05b27e68a78d3a9b
child 2287 74130dd704cb547203adaaf9e120a9468f988e04
push idunknown
push userunknown
push dateunknown
reviewerswtc, dbaron
bugs99561
Workaround fix for a stall on launch on dual CPU OS X machines, that is caused by a race condition entering the critical section. Bug 99561. r=wtc, a=dbaron
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();
     }
 }
 
 
 //##############################################################################
 //##############################################################################