Skip to content

Commit 03cac68

Browse files
committed
---
yaml --- r: 11657 b: refs/heads/master c: ee991ca h: refs/heads/master i: 11655: 2e9c18f v: v3
1 parent 1112f55 commit 03cac68

File tree

5 files changed

+13
-2
lines changed

5 files changed

+13
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 32f7818e7f08c67417720c7883f1400199632766
2+
refs/heads/master: ee991cae81c644a5f536acb49fff59ec769e61c7
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/libcore/comm.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ native mod rustrt {
4444
fn del_port(po: *rust_port);
4545
fn rust_port_begin_detach(po: *rust_port,
4646
yield: *ctypes::uintptr_t);
47+
fn rust_port_end_detach(po: *rust_port);
4748
fn get_port_id(po: *rust_port) -> port_id;
4849
fn rust_port_size(po: *rust_port) -> ctypes::size_t;
4950
fn port_recv(dptr: *uint, po: *rust_port,
@@ -92,6 +93,7 @@ resource port_ptr<T: send>(po: *rust_port) {
9293
// in a bogus state.
9394
task::yield();
9495
}
96+
rustrt::rust_port_end_detach(po);
9597

9698
// Drain the port so that all the still-enqueued items get dropped
9799
while rustrt::rust_port_size(po) > 0u {

trunk/src/rt/rust_builtin.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,16 @@ rust_port_begin_detach(rust_port *port, uintptr_t *yield) {
488488
port->begin_detach(yield);
489489
}
490490

491+
extern "C" CDECL void
492+
rust_port_end_detach(rust_port *port) {
493+
port->end_detach();
494+
}
495+
491496
extern "C" CDECL void
492497
del_port(rust_port *port) {
493498
rust_task *task = rust_task_thread::get_task();
494499
LOG(task, comm, "del_port(0x%" PRIxPTR ")", (uintptr_t) port);
495500
A(task->thread, port->get_ref_count() == 0, "Expected port ref_count == 0");
496-
port->end_detach();
497501
delete port;
498502
}
499503

trunk/src/rt/rust_port.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ void rust_port::begin_detach(uintptr_t *yield) {
4444
}
4545

4646
void rust_port::end_detach() {
47+
// FIXME: For some reason we can sometimes get here without the
48+
// refcount decreasing to 0. This is definitely a bug
49+
while (get_ref_count() != 0) { }
50+
4751
// Just take the lock to make sure that the thread that signaled
4852
// the detach_cond isn't still holding it
4953
scoped_lock with(detach_lock);

trunk/src/rt/rustrt.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ rust_list_files
3535
rust_log_console_on
3636
rust_log_console_off
3737
rust_port_begin_detach
38+
rust_port_end_detach
3839
rust_port_size
3940
rust_process_wait
4041
rust_ptr_eq

0 commit comments

Comments
 (0)