From 5bb4a12900969b3250c490a5e0682c658fe65ba8 Mon Sep 17 00:00:00 2001 From: Ben Blum Date: Fri, 20 Jul 2012 18:06:17 -0400 Subject: [1/4 for #2365, #2671] Fix create/kill race with schedulers and tasks during rust_kernel::fail --- src/rt/rust_task.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/rt/rust_task.cpp') 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(). -- cgit 1.4.1-3-g733a5