summaryrefslogtreecommitdiff
path: root/rts/Schedule.c
diff options
context:
space:
mode:
authorSimon Marlow <simonmar@microsoft.com>2007-07-24 15:30:57 +0000
committerSimon Marlow <simonmar@microsoft.com>2007-07-24 15:30:57 +0000
commit681aad99cb29ce54f72ec2a916fb1aab0fa0fabb (patch)
tree65e13d3bc1acad8b859e63886c5e5ea429f7236f /rts/Schedule.c
parent1bd1fb932375bc4b065cc8de23f0d251e8075395 (diff)
downloadhaskell-681aad99cb29ce54f72ec2a916fb1aab0fa0fabb.tar.gz
hs_exit()/shutdownHaskell(): wait for outstanding foreign calls to complete before returning
This is pertinent to #1177. When shutting down a DLL, we need to be sure that there are no OS threads that can return to the code that we are about to unload, and previously the threaded RTS was unsafe in this respect. When exiting a standalone program we don't have to be quite so paranoid: all the code will disappear at the same time as any running threads. Happily exiting a program happens via a different path: shutdownHaskellAndExit(). If we're about to exit(), then there's no need to wait for foreign calls to complete.
Diffstat (limited to 'rts/Schedule.c')
-rw-r--r--rts/Schedule.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/rts/Schedule.c b/rts/Schedule.c
index 441e97924e..afd8c28a08 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -2577,7 +2577,8 @@ initScheduler(void)
}
void
-exitScheduler( void )
+exitScheduler( rtsBool wait_foreign )
+ /* see Capability.c, shutdownCapability() */
{
Task *task = NULL;
@@ -2599,7 +2600,7 @@ exitScheduler( void )
nat i;
for (i = 0; i < n_capabilities; i++) {
- shutdownCapability(&capabilities[i], task);
+ shutdownCapability(&capabilities[i], task, wait_foreign);
}
boundTaskExiting(task);
stopTaskManager();