about summary refs log tree commit diff
path: root/src/rt/rust_task.h
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-05-15 14:03:59 -0700
committerBrian Anderson <banderson@mozilla.com>2012-05-15 16:13:42 -0700
commit5d625af9f944c7b6567c443a6f796e30dbb01bf2 (patch)
tree469e7cf76a36fa85f92c37f632e0a3fe4e42c7bc /src/rt/rust_task.h
parentc424b7f847bbec50d01b00a89e044d80b8eb59f8 (diff)
downloadrust-5d625af9f944c7b6567c443a6f796e30dbb01bf2.tar.gz
rust-5d625af9f944c7b6567c443a6f796e30dbb01bf2.zip
rt: Make task killing synchronization possibly more correct
I could not come up with a test but this looks better to me.
Diffstat (limited to 'src/rt/rust_task.h')
-rw-r--r--src/rt/rust_task.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h
index 1867c8f4ed8..69a56e425de 100644
--- a/src/rt/rust_task.h
+++ b/src/rt/rust_task.h
@@ -149,7 +149,7 @@ private:
     rust_cond *cond;
     const char *cond_name;
 
-    // Protects the killed flag
+    // Protects the killed flag, disallow_kill flag, reentered_rust_stack
     lock_and_signal kill_lock;
     // Indicates that the task was killed and needs to unwind
     bool killed;
@@ -372,7 +372,10 @@ rust_task::call_on_rust_stack(void *args, void *fn_ptr) {
     assert(next_rust_sp);
 
     bool had_reentered_rust_stack = reentered_rust_stack;
-    reentered_rust_stack = true;
+    {
+        scoped_lock with(kill_lock);
+        reentered_rust_stack = true;
+    }
 
     uintptr_t prev_c_sp = next_c_sp;
     next_c_sp = get_sp();
@@ -384,7 +387,10 @@ rust_task::call_on_rust_stack(void *args, void *fn_ptr) {
     __morestack(args, fn_ptr, sp);
 
     next_c_sp = prev_c_sp;
-    reentered_rust_stack = had_reentered_rust_stack;
+    {
+        scoped_lock with(kill_lock);
+        reentered_rust_stack = had_reentered_rust_stack;
+    }
 }
 
 inline void