From 3d9023fa4ddc8dbb5d9be0e4e4ef5c284c6b077a Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 11 Nov 2011 15:34:35 -0800 Subject: 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 --- src/rt/rust_builtin.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/rt/rust_builtin.cpp') 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(); } } -- cgit 1.4.1-3-g733a5