about summary refs log tree commit diff
path: root/src/rt/rust_task.cpp
diff options
context:
space:
mode:
authorBen Blum <bblum@andrew.cmu.edu>2012-07-20 18:06:17 -0400
committerBen Blum <bblum@andrew.cmu.edu>2012-07-20 19:23:19 -0400
commit5bb4a12900969b3250c490a5e0682c658fe65ba8 (patch)
tree9fee7318849691fd35658af7363dfdd8d433b0c9 /src/rt/rust_task.cpp
parentf55999fd7a03b4f876e69e94e491d3c30bf0c076 (diff)
downloadrust-5bb4a12900969b3250c490a5e0682c658fe65ba8.tar.gz
rust-5bb4a12900969b3250c490a5e0682c658fe65ba8.zip
[1/4 for #2365, #2671] Fix create/kill race with schedulers and tasks during rust_kernel::fail
Diffstat (limited to 'src/rt/rust_task.cpp')
-rw-r--r--src/rt/rust_task.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index 84984d499e9..c28e3350bf2 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -257,8 +257,17 @@ rust_task::yield(bool *killed) {
 void
 rust_task::kill() {
     scoped_lock with(lifecycle_lock);
+    kill_inner();
+}
+
+void rust_task::kill_inner() {
+    lifecycle_lock.must_have_lock();
 
-    // XXX: bblum: kill/kill race
+    // Multiple kills should be able to safely race, but check anyway.
+    if (killed) {
+        LOG(this, task, "task %s @0x%" PRIxPTR " already killed", name, this);
+        return;
+    }
 
     // Note the distinction here: kill() is when you're in an upcall
     // from task A and want to force-fail task B, you do B->kill().