core: Don't fail during port dtor
This commit is contained in:
@@ -93,7 +93,8 @@ fn listen<T: send, U>(f: fn(chan<T>) -> U) -> U {
|
|||||||
f(po.chan())
|
f(po.chan())
|
||||||
}
|
}
|
||||||
|
|
||||||
resource port_ptr<T: send>(po: *rust_port) {
|
resource port_ptr<T: send>(po: *rust_port) unsafe {
|
||||||
|
task::unkillable {||
|
||||||
// Once the port is detached it's guaranteed not to receive further
|
// Once the port is detached it's guaranteed not to receive further
|
||||||
// messages
|
// messages
|
||||||
let yield = 0u;
|
let yield = 0u;
|
||||||
@@ -113,6 +114,7 @@ resource port_ptr<T: send>(po: *rust_port) {
|
|||||||
}
|
}
|
||||||
rustrt::del_port(po);
|
rustrt::del_port(po);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[doc = "
|
#[doc = "
|
||||||
Internal function for converting from a channel to a port
|
Internal function for converting from a channel to a port
|
||||||
@@ -459,3 +461,24 @@ fn test_listen() {
|
|||||||
assert parent.recv() == "oatmeal-salad";
|
assert parent.recv() == "oatmeal-salad";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[ignore(cfg(target_os="win32"))]
|
||||||
|
fn test_port_detach_fail() {
|
||||||
|
iter::repeat(100u) {||
|
||||||
|
let builder = task::builder();
|
||||||
|
task::unsupervise(builder);
|
||||||
|
task::run(builder) {||
|
||||||
|
let po = port();
|
||||||
|
let ch = po.chan();
|
||||||
|
|
||||||
|
task::spawn {||
|
||||||
|
fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
task::spawn {||
|
||||||
|
ch.send(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user