diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-03-02 16:33:24 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-03-02 16:33:33 -0800 |
| commit | 04d9cc18a569f5d8a8b7c2c07a42259af41d7cb3 (patch) | |
| tree | f8a14162b39a7a355dc2bdda74551771483f603d /src/rt/rust_task.cpp | |
| parent | f4ce965ce70f7f7ffa62df721d083cb3eafeb19d (diff) | |
| download | rust-04d9cc18a569f5d8a8b7c2c07a42259af41d7cb3.tar.gz rust-04d9cc18a569f5d8a8b7c2c07a42259af41d7cb3.zip | |
rt: Protect rust_task::supervisor with a lock
Diffstat (limited to 'src/rt/rust_task.cpp')
| -rw-r--r-- | src/rt/rust_task.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 106190d76f8..756dc0fbc4d 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -77,7 +77,6 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state, state(state), cond(NULL), cond_name("none"), - supervisor(spawner), list_index(-1), next_port_id(0), rendezvous_ptr(0), @@ -92,7 +91,8 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state, reentered_rust_stack(false), c_stack(NULL), next_c_sp(0), - next_rust_sp(0) + next_rust_sp(0), + supervisor(spawner) { LOGPTR(thread, "new task", (uintptr_t)this); DLOG(thread, task, "sizeof(task) = %d (0x%x)", sizeof *this, sizeof *this); @@ -103,6 +103,7 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state, } } +// NB: This does not always run on the task's scheduler thread void rust_task::delete_this() { @@ -112,8 +113,11 @@ rust_task::delete_this() name, (uintptr_t)this, ref_count); // FIXME: We should do this when the task exits, not in the destructor - if (supervisor) { - supervisor->deref(); + { + scoped_lock with(supervisor_lock); + if (supervisor) { + supervisor->deref(); + } } /* FIXME: tighten this up, there are some more @@ -302,6 +306,7 @@ rust_task::conclude_failure() { void rust_task::fail_parent() { + scoped_lock with(supervisor_lock); if (supervisor) { DLOG(thread, task, "task %s @0x%" PRIxPTR @@ -317,6 +322,7 @@ rust_task::fail_parent() { void rust_task::unsupervise() { + scoped_lock with(supervisor_lock); if (supervisor) { DLOG(thread, task, "task %s @0x%" PRIxPTR |
