diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-11-16 16:44:08 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-11-16 17:22:14 -0800 |
| commit | 342dc21d2ceda92319e11937a553383e3e39d341 (patch) | |
| tree | 90597db8de7b1e1c8d01ff3ed135f8fdcfd24e2d /src/rt/rust_builtin.cpp | |
| parent | 809ca13bfa79211aebeef3491f1553ee22fde45b (diff) | |
| download | rust-342dc21d2ceda92319e11937a553383e3e39d341.tar.gz rust-342dc21d2ceda92319e11937a553383e3e39d341.zip | |
Disconnect ports before draining them. Issue #1155
Diffstat (limited to 'src/rt/rust_builtin.cpp')
| -rw-r--r-- | src/rt/rust_builtin.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index da7280211fd..aed3eda7156 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -468,10 +468,23 @@ new_port(size_t unit_sz) { } extern "C" CDECL void +rust_port_detach(rust_port *port) { + rust_task *task = rust_scheduler::get_task(); + LOG(task, comm, "rust_port_detach(0x%" PRIxPTR ")", (uintptr_t) port); + port->detach(); + // FIXME: Busy waiting until we're the only ref + bool done = false; + while (!done) { + scoped_lock with(port->lock); + done = port->ref_count == 1; + } +} + +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); + A(task->sched, port->ref_count == 1, "Expected port ref_count == 1"); port->deref(); } |
