Terminate blocked receive packets on failure. Fixes #3168.
This commit is contained in:
parent
0101125a96
commit
4808d59909
@ -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 => {
|
||||
|
19
src/test/run-pass/issue-3168.rs
Normal file
19
src/test/run-pass/issue-3168.rs
Normal file
@ -0,0 +1,19 @@
|
||||
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!");
|
||||
}
|
Loading…
Reference in New Issue
Block a user