X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=rts%2FTask.c;h=0ec60f750854cf25fbf2838a9a55ec1d8645834d;hp=4a630843b725cec6aa1afaff7e26417dac2a06ae;hb=006a18ea83799c0d4255071a2f8c08d3e9c7d84f;hpb=1f801e3abd16559f2120b7f482b19deb0c43a0c7 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--;