From 1f6f52a75aa99e4aa3cb5ac9455958cbe115a7e7 Mon Sep 17 00:00:00 2001 From: "wtc%netscape.com" Date: Fri, 1 Sep 2000 18:26:28 +0000 Subject: [PATCH] Bugzilla bug #30746: the primordial thread should wait for the timer manager thread to start only if the timer manager thread is a local thread, otherwise in native-threads-only mode, if NSPR is initialized by a DLL, the primordial thread may be hung in PR_WaitCondVar because the (native) timer manager thread does not get to run until the DLL is initialized. --- nsprpub/pr/src/io/prmwait.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/nsprpub/pr/src/io/prmwait.c b/nsprpub/pr/src/io/prmwait.c index 8ddcb3756c3..40ed519804d 100644 --- a/nsprpub/pr/src/io/prmwait.c +++ b/nsprpub/pr/src/io/prmwait.c @@ -90,7 +90,9 @@ static void TimerManager(void *arg) PR_Lock(tm_vars.ml); /* tell the primordial thread that we have started */ tm_vars.manager_started = PR_TRUE; - PR_NotifyCondVar(tm_vars.cancel_timer); + if (!_native_threads_only) { + PR_NotifyCondVar(tm_vars.cancel_timer); + } while (1) { if (PR_CLIST_IS_EMPTY(&tm_vars.timer_queue)) @@ -214,11 +216,16 @@ static PRStatus TimerInit(void) { goto failed; } - /* wait until the timer manager thread starts */ - PR_Lock(tm_vars.ml); - while (!tm_vars.manager_started) - PR_WaitCondVar(tm_vars.cancel_timer, PR_INTERVAL_NO_TIMEOUT); - PR_Unlock(tm_vars.ml); + /* + * Need to wait until the timer manager thread starts + * if the timer manager thread is a local thread. + */ + if (!_native_threads_only) { + PR_Lock(tm_vars.ml); + while (!tm_vars.manager_started) + PR_WaitCondVar(tm_vars.cancel_timer, PR_INTERVAL_NO_TIMEOUT); + PR_Unlock(tm_vars.ml); + } return PR_SUCCESS; failed: