Child tasks take a ref to their parents
This is so that when a child dies after the parent, it still holds a valid pointer and can call supervisor->kill() safely.
This commit is contained in:
parent
25ae3d655c
commit
c337fd5467
2 changed files with 24 additions and 0 deletions
|
@ -86,6 +86,9 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state,
|
|||
|
||||
stk = new_stk(sched, this, 0);
|
||||
user.rust_sp = stk->limit;
|
||||
if (supervisor) {
|
||||
supervisor->ref();
|
||||
}
|
||||
}
|
||||
|
||||
rust_task::~rust_task()
|
||||
|
@ -107,6 +110,10 @@ rust_task::~rust_task()
|
|||
}
|
||||
}
|
||||
|
||||
if (supervisor) {
|
||||
supervisor->deref();
|
||||
}
|
||||
|
||||
kernel->release_task_id(user.id);
|
||||
|
||||
/* FIXME: tighten this up, there are some more
|
||||
|
@ -294,6 +301,9 @@ rust_task::unsupervise()
|
|||
"task %s @0x%" PRIxPTR
|
||||
" disconnecting from supervisor %s @0x%" PRIxPTR,
|
||||
name, this, supervisor->name, supervisor);
|
||||
if (supervisor) {
|
||||
supervisor->deref();
|
||||
}
|
||||
supervisor = NULL;
|
||||
propagate_failure = false;
|
||||
}
|
||||
|
|
14
src/test/run-fail/spawnfail.rs
Normal file
14
src/test/run-fail/spawnfail.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Currently failure doesn't propagate correctly to owning tasks so xfailed
|
||||
// xfail-test
|
||||
// error-pattern:explicit
|
||||
use std;
|
||||
import std::task;
|
||||
|
||||
// We don't want to see any invalid reads
|
||||
fn main() {
|
||||
fn f() {
|
||||
fail;
|
||||
}
|
||||
let g = f;
|
||||
task::spawn(g);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue