summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
681aad9)
Now we don't wait for outstanding IO requests when shutting down at
program exit time, but we still wait when shutting down a DLL (via
hs_exit()). There ought to be a better way to do this, but
terminating the threads forcibly is not a good idea (it never is: the
thread might be holding a mutex when it dies, for example).
I plan to add some docs to the user guide to describe how to shut
down a DLL properly.
#endif
#if defined(mingw32_HOST_OS) && !defined(THREADED_RTS)
#endif
#if defined(mingw32_HOST_OS) && !defined(THREADED_RTS)
+ shutdownAsyncIO(wait_foreign);
#endif
/* free hash table storage */
#endif
/* free hash table storage */
+shutdownAsyncIO(rtsBool wait_threads)
+ ShutdownIOManager(wait_threads);
if (completed_req_event != INVALID_HANDLE_VALUE) {
CloseHandle(completed_req_event);
completed_req_event = INVALID_HANDLE_VALUE;
if (completed_req_event != INVALID_HANDLE_VALUE) {
CloseHandle(completed_req_event);
completed_req_event = INVALID_HANDLE_VALUE;
extern unsigned int addDelayRequest(int msecs);
extern unsigned int addDoProcRequest(void* proc, void* param);
extern int startupAsyncIO(void);
extern unsigned int addDelayRequest(int msecs);
extern unsigned int addDoProcRequest(void* proc, void* param);
extern int startupAsyncIO(void);
-extern void shutdownAsyncIO(void);
+extern void shutdownAsyncIO(rtsBool wait_threads);
extern int awaitRequests(rtsBool wait);
extern int awaitRequests(rtsBool wait);
return depositWorkItem(reqID, wItem);
}
return depositWorkItem(reqID, wItem);
}
-void ShutdownIOManager ( void )
+void ShutdownIOManager ( rtsBool wait_threads )
{
int num;
SetEvent(ioMan->hExitEvent);
{
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);
+ free(ioMan);
+ ioMan = NULL;
- FreeWorkQueue(ioMan->workQueue);
- CloseHandle(ioMan->hExitEvent);
- free(ioMan);
- ioMan = NULL;
}
/* Keep track of WorkItems currently being serviced. */
}
/* Keep track of WorkItems currently being serviced. */
* Starting up and shutting down.
*/
extern BOOL StartIOManager ( void );
* Starting up and shutting down.
*/
extern BOOL StartIOManager ( void );
-extern void ShutdownIOManager ( void );
+extern void ShutdownIOManager ( rtsBool wait_threads );
/*
* Adding I/O and delay requests. With each request a
/*
* Adding I/O and delay requests. With each request a