提交 4808d599 编写于 作者: E Eric Holk

Terminate blocked receive packets on failure. Fixes #3168.

上级 0101125a
......@@ -396,6 +396,23 @@ fn try_recv<T: send, Tbuffer: send>(-p: recv_packet_buffered<T, Tbuffer>)
let p_ = p.unwrap();
let p = unsafe { &*p_ };
struct drop_state {
p: &packet_header;
drop {
if task::failing() {
io::println("failing!");
self.p.state = terminated;
let old_task = swap_task(self.p.blocked_task, ptr::null());
if !old_task.is_null() {
rustrt::rust_task_deref(old_task);
}
}
}
};
let _drop_state = drop_state { p: &p.header };
// optimistic path
match p.header.state {
full => {
......
fn main() {
let (c,p) = pipes::stream();
do task::try {
let (c2,p2) = pipes::stream();
do task::spawn {
p2.recv();
#error["brother fails"];
fail;
}
let (c3,p3) = pipes::stream();
c.send(c3);
c2.send(());
#error["child blocks"];
p3.recv();
};
#error["parent tries"];
assert !p.recv().try_send(());
#error("all done!");
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册