rt: Add a hack to fix a port detach bug
This commit is contained in:
parent
32f7818e7f
commit
ee991cae81
@ -44,6 +44,7 @@ native mod rustrt {
|
||||
fn del_port(po: *rust_port);
|
||||
fn rust_port_begin_detach(po: *rust_port,
|
||||
yield: *ctypes::uintptr_t);
|
||||
fn rust_port_end_detach(po: *rust_port);
|
||||
fn get_port_id(po: *rust_port) -> port_id;
|
||||
fn rust_port_size(po: *rust_port) -> ctypes::size_t;
|
||||
fn port_recv(dptr: *uint, po: *rust_port,
|
||||
@ -92,6 +93,7 @@ resource port_ptr<T: send>(po: *rust_port) {
|
||||
// in a bogus state.
|
||||
task::yield();
|
||||
}
|
||||
rustrt::rust_port_end_detach(po);
|
||||
|
||||
// Drain the port so that all the still-enqueued items get dropped
|
||||
while rustrt::rust_port_size(po) > 0u {
|
||||
|
@ -488,12 +488,16 @@ rust_port_begin_detach(rust_port *port, uintptr_t *yield) {
|
||||
port->begin_detach(yield);
|
||||
}
|
||||
|
||||
extern "C" CDECL void
|
||||
rust_port_end_detach(rust_port *port) {
|
||||
port->end_detach();
|
||||
}
|
||||
|
||||
extern "C" CDECL void
|
||||
del_port(rust_port *port) {
|
||||
rust_task *task = rust_task_thread::get_task();
|
||||
LOG(task, comm, "del_port(0x%" PRIxPTR ")", (uintptr_t) port);
|
||||
A(task->thread, port->get_ref_count() == 0, "Expected port ref_count == 0");
|
||||
port->end_detach();
|
||||
delete port;
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,10 @@ void rust_port::begin_detach(uintptr_t *yield) {
|
||||
}
|
||||
|
||||
void rust_port::end_detach() {
|
||||
// FIXME: For some reason we can sometimes get here without the
|
||||
// refcount decreasing to 0. This is definitely a bug
|
||||
while (get_ref_count() != 0) { }
|
||||
|
||||
// Just take the lock to make sure that the thread that signaled
|
||||
// the detach_cond isn't still holding it
|
||||
scoped_lock with(detach_lock);
|
||||
|
@ -35,6 +35,7 @@ rust_list_files
|
||||
rust_log_console_on
|
||||
rust_log_console_off
|
||||
rust_port_begin_detach
|
||||
rust_port_end_detach
|
||||
rust_port_size
|
||||
rust_process_wait
|
||||
rust_ptr_eq
|
||||
|
Loading…
Reference in New Issue
Block a user