Move the freeing of Capabilities later in the shutdown sequence
[ghc-hetmet.git] / rts / Schedule.c
index 2e9d0dd..8ab964d 100644 (file)
@@ -399,6 +399,7 @@ schedule (Capability *initialCapability, Task *task)
     //     ASSERT_FULL_CAPABILITY_INVARIANTS(cap,task);
     }
 
+  yield:
     scheduleYield(&cap,task);
     if (emptyRunQueue(cap)) continue; // look for work again
 #endif
@@ -565,7 +566,7 @@ run_thread:
        debugTrace(DEBUG_sched,
                   "--<< thread %lu (%s) stopped: blocked",
                   (unsigned long)t->id, whatNext_strs[t->what_next]);
-       continue;
+        goto yield;
     }
 #endif
 
@@ -2113,14 +2114,13 @@ exitScheduler(
        boundTaskExiting(task);
        stopTaskManager();
     }
-#else
-    freeCapability(&MainCapability);
 #endif
 }
 
 void
 freeScheduler( void )
 {
+    freeCapabilities();
     freeTaskManager();
     if (n_capabilities != 1) {
         stgFree(capabilities);