1
Fork 0

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
This commit is contained in:
Brian Anderson 2011-11-11 15:34:35 -08:00
parent 07771ec25b
commit 3d9023fa4d
4 changed files with 20 additions and 26 deletions

View file

@ -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();
}
}