about summary refs log tree commit diff
path: root/src/rt/rust_kernel.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-12-20 20:55:52 -0800
committerBrian Anderson <banderson@mozilla.com>2011-12-20 20:56:06 -0800
commit854daaec0c4cf0c236e46b45a1254c85a8b352db (patch)
tree32d39266b29bf243914cc1d39350f30df51dafaf /src/rt/rust_kernel.cpp
parentaeadc6269ef76f4425a49d892ceac7ea311ef5c1 (diff)
downloadrust-854daaec0c4cf0c236e46b45a1254c85a8b352db.tar.gz
rust-854daaec0c4cf0c236e46b45a1254c85a8b352db.zip
rt: Lock before using the random number generator
Seeing crashes here trying to stress test concurrent tasks
Diffstat (limited to 'src/rt/rust_kernel.cpp')
-rw-r--r--src/rt/rust_kernel.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp
index 347b7907b53..f009541053d 100644
--- a/src/rt/rust_kernel.cpp
+++ b/src/rt/rust_kernel.cpp
@@ -150,13 +150,11 @@ rust_kernel::fail() {
 
 rust_task_id
 rust_kernel::create_task(rust_task *spawner, const char *name) {
+    scoped_lock with(_kernel_lock);
     rust_scheduler *thread = threads[isaac_rand(&rctx) % num_threads];
     rust_task *t = thread->create_task(spawner, name);
-    {
-        scoped_lock with(_kernel_lock);
-        t->user.id = max_id++;
-        task_table.put(t->user.id, t);
-    }
+    t->user.id = max_id++;
+    task_table.put(t->user.id, t);
     return t->user.id;
 }