X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fwin32%2FIOManager.c;h=81dedda569874775114bce599334ac720b3662e0;hb=8604da0136707cc14845d14a88c2272fe576b6d0;hp=764be698722627b2b92c5cbfa20ae04b38e919ff;hpb=de6c8e5293c9ef68b597ab2e6d55c3f42a283489;p=ghc-hetmet.git diff --git a/rts/win32/IOManager.c b/rts/win32/IOManager.c index 764be69..81dedda 100644 --- a/rts/win32/IOManager.c +++ b/rts/win32/IOManager.c @@ -190,7 +190,7 @@ IOWorkerProc(PVOID param) * * Note: Sleep() is in milliseconds, not micros. */ - Sleep(work->workData.delayData.msecs / 1000); + Sleep((work->workData.delayData.msecs + 999) / 1000); len = work->workData.delayData.msecs; complData = NULL; fd = 0; @@ -443,25 +443,29 @@ AddProcRequest ( void* proc, return depositWorkItem(reqID, wItem); } -void ShutdownIOManager ( void ) +void ShutdownIOManager ( rtsBool wait_threads ) { int num; SetEvent(ioMan->hExitEvent); - /* Wait for all worker threads to die. */ - for (;;) { - EnterCriticalSection(&ioMan->manLock); - num = ioMan->numWorkers; - LeaveCriticalSection(&ioMan->manLock); - if (num == 0) - break; - Sleep(10); + if (wait_threads) { + /* Wait for all worker threads to die. */ + for (;;) { + EnterCriticalSection(&ioMan->manLock); + num = ioMan->numWorkers; + LeaveCriticalSection(&ioMan->manLock); + if (num == 0) + break; + Sleep(10); + } + FreeWorkQueue(ioMan->workQueue); + CloseHandle(ioMan->hExitEvent); + DeleteCriticalSection(&ioMan->active_work_lock); + DeleteCriticalSection(&ioMan->manLock); + free(ioMan); + ioMan = NULL; } - FreeWorkQueue(ioMan->workQueue); - CloseHandle(ioMan->hExitEvent); - free(ioMan); - ioMan = NULL; } /* Keep track of WorkItems currently being serviced. */