make disallow_kill an int for nested unkillables (closes #2782)

This commit is contained in:
Ben Blum
2012-07-05 19:55:01 -04:00
parent 7f56d74072
commit 7b3add0632
3 changed files with 7 additions and 6 deletions

View File

@@ -609,7 +609,7 @@ mod tests {
#[test] #[should_fail] #[ignore(cfg(windows))] #[test] #[should_fail] #[ignore(cfg(windows))]
fn test_asymmetric_link() { fn test_asymmetric_link() {
let l = create::<int>(); let l = create::<int>();
let one = l.push_n(1); let _one = l.push_n(1);
let two = l.push_n(2); let two = l.push_n(2);
two.prev = none; two.prev = none;
l.assert_consistent(); l.assert_consistent();

View File

@@ -38,7 +38,7 @@ rust_task::rust_task(rust_sched_loop *sched_loop, rust_task_state state,
cond_name("none"), cond_name("none"),
killed(false), killed(false),
reentered_rust_stack(false), reentered_rust_stack(false),
disallow_kill(false), disallow_kill(0),
c_stack(NULL), c_stack(NULL),
next_c_sp(0), next_c_sp(0),
next_rust_sp(0), next_rust_sp(0),
@@ -237,7 +237,7 @@ rust_task::must_fail_from_being_killed() {
bool bool
rust_task::must_fail_from_being_killed_unlocked() { rust_task::must_fail_from_being_killed_unlocked() {
kill_lock.must_have_lock(); kill_lock.must_have_lock();
return killed && !reentered_rust_stack && !disallow_kill; return killed && !reentered_rust_stack && disallow_kill == 0;
} }
// Only run this on the rust stack // Only run this on the rust stack
@@ -683,13 +683,14 @@ rust_task::on_rust_stack() {
void void
rust_task::inhibit_kill() { rust_task::inhibit_kill() {
scoped_lock with(kill_lock); scoped_lock with(kill_lock);
disallow_kill = true; disallow_kill++;
} }
void void
rust_task::allow_kill() { rust_task::allow_kill() {
scoped_lock with(kill_lock); scoped_lock with(kill_lock);
disallow_kill = false; assert(disallow_kill > 0 && "Illegal allow_kill(): already killable!");
disallow_kill--;
} }
// //

View File

@@ -181,7 +181,7 @@ private:
bool killed; bool killed;
// Indicates that we've called back into Rust from C // Indicates that we've called back into Rust from C
bool reentered_rust_stack; bool reentered_rust_stack;
bool disallow_kill; int disallow_kill;
// The stack used for running C code, borrowed from the scheduler thread // The stack used for running C code, borrowed from the scheduler thread
stk_seg *c_stack; stk_seg *c_stack;