diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-11-11 15:34:35 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-11-11 16:11:31 -0800 |
| commit | 3d9023fa4ddc8dbb5d9be0e4e4ef5c284c6b077a (patch) | |
| tree | ff4ed0e61a85f4f11e4b094fac90d488462403bf /src/rt/rust_builtin.cpp | |
| parent | 07771ec25bc394a4a053252a2b5441f3160a0568 (diff) | |
| download | rust-3d9023fa4ddc8dbb5d9be0e4e4ef5c284c6b077a.tar.gz rust-3d9023fa4ddc8dbb5d9be0e4e4ef5c284c6b077a.zip | |
rt: Take the task lock when dropping port refcounts
Sucks, but otherwise there are races when one task drops the refcount to zero followed by another bumping it again
Diffstat (limited to 'src/rt/rust_builtin.cpp')
| -rw-r--r-- | src/rt/rust_builtin.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 30b915f4e96..e8109ea7a04 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -471,6 +471,7 @@ extern "C" CDECL void del_port(rust_port *port) { rust_task *task = rust_scheduler::get_task(); LOG(task, comm, "del_port(0x%" PRIxPTR ")", (uintptr_t) port); + scoped_lock with(task->lock); port->deref(); } @@ -487,11 +488,12 @@ chan_id_send(type_desc *t, rust_task_id target_task_id, rust_task *target_task = task->kernel->get_task_by_id(target_task_id); if(target_task) { rust_port *port = target_task->get_port_by_id(target_port_id); - target_task->deref(); if(port) { port->send(sptr); + scoped_lock with(target_task->lock); port->deref(); } + target_task->deref(); } } |
