diff options
| author | Simon Marlow <marlowsd@gmail.com> | 2010-01-27 13:54:30 +0000 |
|---|---|---|
| committer | Simon Marlow <marlowsd@gmail.com> | 2010-01-27 13:54:30 +0000 |
| commit | bb7b45dcf16118fb03bf28aea08a168ac6598a33 (patch) | |
| tree | c00d93fb485c63f1a6fb4b1b6de6daaf0cc949d4 /rts/win32 | |
| parent | cb7e8821e9c08537bce370b56442c02ba28decd3 (diff) | |
| download | haskell-bb7b45dcf16118fb03bf28aea08a168ac6598a33.tar.gz | |
Don't Terminate the ticker thread (#3748)
Diffstat (limited to 'rts/win32')
| -rw-r--r-- | rts/win32/Ticker.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/rts/win32/Ticker.c b/rts/win32/Ticker.c index 6be1b3a7c6..929e6f4086 100644 --- a/rts/win32/Ticker.c +++ b/rts/win32/Ticker.c @@ -127,7 +127,7 @@ stopTicker(void) } void -exitTicker(void) +exitTicker (rtsBool wait) { // We must wait for the ticker thread to terminate, since if we // are in a DLL that is about to be unloaded, the ticker thread @@ -138,10 +138,20 @@ exitTicker(void) DWORD exitCode; ticker_state = TickerExit; SetEvent(hStopEvent); - while (1) { - WaitForSingleObject(tickThread, 20); + while (wait) { + // See #3748: + // + // when the RTS is compiled into a DLL (wait==rtsTrue), + // the ticker thread must stop before we exit, or chaos + // will ensue. We can't kill it, because it may be + // holding a lock. + // + // When not compiled into a DLL, we wait for + // the thread out of courtesy, but give up after 200ms if + // it still hasn't stopped. + WaitForSingleObject(tickThread, 200); if (!GetExitCodeThread(tickThread, &exitCode)) { - return 1; + return; } if (exitCode != STILL_ACTIVE) { tickThread = INVALID_HANDLE_VALUE; @@ -149,9 +159,8 @@ exitTicker(void) CloseHandle(hStopEvent); hStopEvent = INVALID_HANDLE_VALUE; } - return 0; + return; } - TerminateThread(tickThread, 0); } } } |
