From: simonmar Date: Mon, 15 Dec 2003 14:31:48 +0000 (+0000) Subject: [project @ 2003-12-15 14:31:48 by simonmar] X-Git-Tag: Approx_11550_changesets_converted~201 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=622da08564f02443b40426a19c25f82e89071cac;p=ghc-hetmet.git [project @ 2003-12-15 14:31:48 by simonmar] Fix locking bug in awaitEvent(): in one code path it could return with sched_lock unlocked. --- diff --git a/ghc/rts/win32/AwaitEvent.c b/ghc/rts/win32/AwaitEvent.c index a8f73ff..0df8023 100644 --- a/ghc/rts/win32/AwaitEvent.c +++ b/ghc/rts/win32/AwaitEvent.c @@ -23,13 +23,18 @@ void awaitEvent(rtsBool wait) { - RELEASE_LOCK(&sched_mutex); + int ret; + do { - /* Try to de-queue completed IO requests */ - if (!awaitRequests(wait)) { - return; - } + /* Try to de-queue completed IO requests + */ + RELEASE_LOCK(&sched_mutex); + ret = awaitRequests(wait); ACQUIRE_LOCK(&sched_mutex); + if (!ret) { + return; /* still hold the lock */ + } + /* we were interrupted, return to the scheduler immediately. */ if (interrupted) { @@ -51,7 +56,6 @@ awaitEvent(rtsBool wait) return; /* still hold the lock */ } #endif - RELEASE_LOCK(&sched_mutex); } while (wait && !interrupted && run_queue_hd == END_TSO_QUEUE); }