about summary refs log tree commit diff
path: root/src/rt/rust_task.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-09-06 18:16:39 -0700
committerBrian Anderson <banderson@mozilla.com>2011-09-07 10:32:58 -0700
commitc337fd5467f52b5f79f653b7e71f945cc8cf09d1 (patch)
tree8c7151c29e0e53578b18a60a96d03e95369da95d /src/rt/rust_task.cpp
parent25ae3d655cef63041d405a45f4797d21f8904502 (diff)
downloadrust-c337fd5467f52b5f79f653b7e71f945cc8cf09d1.tar.gz
rust-c337fd5467f52b5f79f653b7e71f945cc8cf09d1.zip
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.
Diffstat (limited to 'src/rt/rust_task.cpp')
-rw-r--r--src/rt/rust_task.cpp10
1 files changed, 10 insertions, 0 deletions
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;
 }