From c337fd5467f52b5f79f653b7e71f945cc8cf09d1 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 6 Sep 2011 18:16:39 -0700 Subject: 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. --- src/rt/rust_task.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/rt/rust_task.cpp') diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index ab29b106783..31a3324f1d4 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -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; } -- cgit 1.4.1-3-g733a5