diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-09-14 14:20:13 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-09-14 14:20:41 -0700 |
| commit | 9505d70513ebd38d1a404b1dde3c181f40f86b75 (patch) | |
| tree | ff16cb5e435cf456a5da1fbee44e4e6d02dddd7b | |
| parent | c61f06fde9757e6f1208399be7473f5a50d6e10b (diff) | |
| download | rust-9505d70513ebd38d1a404b1dde3c181f40f86b75.tar.gz rust-9505d70513ebd38d1a404b1dde3c181f40f86b75.zip | |
Make linked task failure work again
| -rw-r--r-- | src/rt/rust_task.cpp | 15 | ||||
| -rw-r--r-- | src/rt/rust_task.h | 2 | ||||
| -rw-r--r-- | src/test/run-fail/linked-failure.rs | 1 |
3 files changed, 14 insertions, 4 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index b861c60b521..e99ccc1d04b 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -74,6 +74,7 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state, local_region(&sched->srv->local_region), _on_wakeup(NULL), failed(false), + killed(false), propagate_failure(true), dynastack(this) { @@ -253,10 +254,19 @@ rust_task::yield(size_t time_in_us) { LOG(this, task, "task %s @0x%" PRIxPTR " yielding for %d us", name, this, time_in_us); + if (killed) { + killed = false; + fail(); + } yield_timer.reset_us(time_in_us); // Return to the scheduler. ctx.next->swap(ctx); + + if (killed) { + killed = false; + fail(); + } } void @@ -270,12 +280,11 @@ rust_task::kill() { // from task A and want to force-fail task B, you do B->kill(). // If you want to fail yourself you do self->fail(). LOG(this, task, "killing task %s @0x%" PRIxPTR, name, this); + // When the task next goes to yield or resume it will fail + killed = true; // Unblock the task so it can unwind. unblock(); - if (NULL == supervisor && propagate_failure) - sched->fail(); - sched->lock.signal(); LOG(this, task, "preparing to unwind task: 0x%" PRIxPTR, this); diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h index fd7013ea0f8..27445c1de2e 100644 --- a/src/rt/rust_task.h +++ b/src/rt/rust_task.h @@ -102,6 +102,8 @@ rust_task : public kernel_owned<rust_task>, rust_cond // Indicates that the task ended in failure bool failed; + // Indicates that the task was killed and needs to unwind + bool killed; bool propagate_failure; lock_and_signal lock; diff --git a/src/test/run-fail/linked-failure.rs b/src/test/run-fail/linked-failure.rs index 24cfff6edb5..289e3d2767c 100644 --- a/src/test/run-fail/linked-failure.rs +++ b/src/test/run-fail/linked-failure.rs @@ -1,7 +1,6 @@ // -*- rust -*- // error-pattern:1 == 2 -// xfail-test use std; import std::task; import std::comm::port; |
