X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FTask.c;h=0ec60f750854cf25fbf2838a9a55ec1d8645834d;hb=d5a9ee0e98a76bca1b41bbc5252e851c88b3ff4c;hp=4a630843b725cec6aa1afaff7e26417dac2a06ae;hpb=1f801e3abd16559f2120b7f482b19deb0c43a0c7;p=ghc-hetmet.git diff --git a/rts/Task.c b/rts/Task.c index 4a63084..0ec60f7 100644 --- a/rts/Task.c +++ b/rts/Task.c @@ -84,15 +84,24 @@ freeTaskManager (void) ACQUIRE_LOCK(&sched_mutex); for (task = all_tasks; task != NULL; task = next) { + next = task->all_link; + if (task->stopped) { + // We only free resources if the Task is not in use. A + // Task may still be in use if we have a Haskell thread in + // a foreign call while we are attempting to shut down the + // RTS (see conc059). #if defined(THREADED_RTS) - closeCondition(&task->cond); - closeMutex(&task->lock); + closeCondition(&task->cond); + closeMutex(&task->lock); #endif - next = task->all_link; - stgFree(task); + stgFree(task); + } } all_tasks = NULL; task_free_list = NULL; +#if defined(THREADED_RTS) + freeThreadLocalKey(¤tTaskKey); +#endif RELEASE_LOCK(&sched_mutex); } @@ -249,6 +258,7 @@ workerTaskStop (Task *task) ASSERT(myTask() == task); #endif + task->cap = NULL; taskTimeStamp(task); task->stopped = rtsTrue; tasksRunning--;