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:
parent
07771ec25b
commit
3d9023fa4d
4 changed files with 20 additions and 26 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue