about summary refs log tree commit diff
path: root/src/rt/rust_task.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-02-14 00:43:45 -0800
committerBrian Anderson <banderson@mozilla.com>2012-02-14 11:24:09 -0800
commitd5e7f0d1134c41757901ccb9e944974042ee3d93 (patch)
tree96a27c2daa6411b57c46f43453088264f573fa47 /src/rt/rust_task.cpp
parent3f4872f03284f4737675a68438350dd2958db229 (diff)
downloadrust-d5e7f0d1134c41757901ccb9e944974042ee3d93.tar.gz
rust-d5e7f0d1134c41757901ccb9e944974042ee3d93.zip
rt: Don't kill tasks while they are in a callback from C
Diffstat (limited to 'src/rt/rust_task.cpp')
-rw-r--r--src/rt/rust_task.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index 65568ad8ed5..14c223ddb91 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -84,11 +84,12 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
     local_region(&thread->srv->local_region),
     boxed(&local_region),
     unwinding(false),
-    killed(false),
     propagate_failure(true),
     dynastack(this),
     cc_counter(0),
     total_stack_sz(0),
+    killed(false),
+    reentered_rust_stack(false),
     c_stack(NULL),
     next_c_sp(0),
     next_rust_sp(0)
@@ -240,17 +241,22 @@ void rust_task::start()
     transition(&thread->newborn_tasks, &thread->running_tasks);
 }
 
+bool
+rust_task::must_fail_from_being_killed() {
+    return killed && !reentered_rust_stack;
+}
+
 // Only run this on the rust stack
 void
 rust_task::yield(bool *killed) {
-    if (this->killed) {
+    if (must_fail_from_being_killed()) {
         *killed = true;
     }
 
     // Return to the scheduler.
     ctx.next->swap(ctx);
 
-    if (this->killed) {
+    if (must_fail_from_being_killed()) {
         *killed = true;
     }
 }