hs_add_root: use use rts_lock()/rts_unlock() for a bit of extra safety
authorSimon Marlow <marlowsd@gmail.com>
Thu, 29 May 2008 11:10:23 +0000 (11:10 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Thu, 29 May 2008 11:10:23 +0000 (11:10 +0000)
rts/RtsStartup.c

index 0ce17fe..774de72 100644 (file)
@@ -330,7 +330,9 @@ hs_add_root(void (*init_root)(void))
 {
     bdescr *bd;
     nat init_sp;
-    Capability *cap = &MainCapability;
+    Capability *cap;
+
+    cap = rts_lock();
 
     if (hs_init_count <= 0) {
        barf("hs_add_root() must be called after hs_init()");
@@ -357,6 +359,8 @@ hs_add_root(void (*init_root)(void))
     // ToDo: make this work in the presence of multiple hs_add_root()s.
     initProfiling2();
 
+    rts_unlock(cap);
+
     // ditto.
 #if defined(THREADED_RTS)
     ioManagerStart();