Permalink
Browse files

hs_add_root: use use rts_lock()/rts_unlock() for a bit of extra safety

  • Loading branch information...
1 parent eacbef6 commit 9367b24fde0c3f5efa5934e69571f5834ed43548 @simonmar simonmar committed May 29, 2008
Showing with 5 additions and 1 deletion.
  1. +5 −1 rts/RtsStartup.c
View
@@ -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();

0 comments on commit 9367b24

Please sign in to comment.