Skip to content

Commit 25cdaba

Browse files
committed
---
yaml --- r: 15811 b: refs/heads/try c: c424b7f h: refs/heads/master i: 15809: 8cc8a2c 15807: a07f342 v: v3
1 parent a804c14 commit 25cdaba

File tree

2 files changed

+41
-18
lines changed

2 files changed

+41
-18
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 7277cd71984e6a09bc2f8a8a828a5e213b485d00
5+
refs/heads/try: c424b7f847bbec50d01b00a89e044d80b8eb59f8
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/libcore/comm.rs

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,27 @@ fn listen<T: send, U>(f: fn(chan<T>) -> U) -> U {
9393
f(po.chan())
9494
}
9595

96-
resource port_ptr<T: send>(po: *rust_port) {
97-
// Once the port is detached it's guaranteed not to receive further
98-
// messages
99-
let yield = 0u;
100-
let yieldp = ptr::addr_of(yield);
101-
rustrt::rust_port_begin_detach(po, yieldp);
102-
if yield != 0u {
103-
// Need to wait for the port to be detached
104-
// FIXME: If this fails then we're going to leave our port
105-
// in a bogus state. (Issue #1988)
106-
task::yield();
107-
}
108-
rustrt::rust_port_end_detach(po);
96+
resource port_ptr<T: send>(po: *rust_port) unsafe {
97+
task::unkillable {||
98+
// Once the port is detached it's guaranteed not to receive further
99+
// messages
100+
let yield = 0u;
101+
let yieldp = ptr::addr_of(yield);
102+
rustrt::rust_port_begin_detach(po, yieldp);
103+
if yield != 0u {
104+
// Need to wait for the port to be detached
105+
// FIXME: If this fails then we're going to leave our port
106+
// in a bogus state. (Issue #1988)
107+
task::yield();
108+
}
109+
rustrt::rust_port_end_detach(po);
109110

110-
// Drain the port so that all the still-enqueued items get dropped
111-
while rustrt::rust_port_size(po) > 0u {
112-
recv_::<T>(po);
111+
// Drain the port so that all the still-enqueued items get dropped
112+
while rustrt::rust_port_size(po) > 0u {
113+
recv_::<T>(po);
114+
}
115+
rustrt::del_port(po);
113116
}
114-
rustrt::del_port(po);
115117
}
116118

117119
#[doc = "
@@ -458,4 +460,25 @@ fn test_listen() {
458460
}
459461
assert parent.recv() == "oatmeal-salad";
460462
}
463+
}
464+
465+
#[test]
466+
#[ignore(cfg(target_os="win32"))]
467+
fn test_port_detach_fail() {
468+
iter::repeat(100u) {||
469+
let builder = task::builder();
470+
task::unsupervise(builder);
471+
task::run(builder) {||
472+
let po = port();
473+
let ch = po.chan();
474+
475+
task::spawn {||
476+
fail;
477+
}
478+
479+
task::spawn {||
480+
ch.send(());
481+
}
482+
}
483+
}
461484
}

0 commit comments

Comments
 (0)