mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-12-22 19:31:35 +00:00
Don't poll handle if closed, prevents panic if child wait finishes before all bytes are read
This commit is contained in:
parent
b94ba5fcfc
commit
0dbe722524
1 changed files with 7 additions and 9 deletions
|
@ -370,22 +370,20 @@ impl AsyncRead for ProcessRead {
|
||||||
} else {
|
} else {
|
||||||
break Poll::Ready(Ok(()));
|
break Poll::Ready(Ok(()));
|
||||||
}
|
}
|
||||||
|
} else if self.closed {
|
||||||
|
// Stop if we're closed
|
||||||
|
break Poll::Ready(Ok(()));
|
||||||
} else if let Some(waker) = self.get_waker(HANDLE_WAKER) {
|
} else if let Some(waker) = self.get_waker(HANDLE_WAKER) {
|
||||||
// only poll handle if we've been explicitly woken
|
// only poll handle if we've been explicitly woken
|
||||||
let mut handle_cx = Context::from_waker(&waker);
|
let mut handle_cx = Context::from_waker(&waker);
|
||||||
|
|
||||||
if let Poll::Ready(res) = Pin::new(&mut self.handle).poll(&mut handle_cx) {
|
if let Poll::Ready(res) = Pin::new(&mut self.handle).poll(&mut handle_cx) {
|
||||||
let error = match res {
|
|
||||||
Ok(()) => continue,
|
|
||||||
Err(e) => e,
|
|
||||||
};
|
|
||||||
|
|
||||||
self.closed = true;
|
self.closed = true;
|
||||||
break Poll::Ready(Err(error));
|
|
||||||
|
if let Err(e) = res {
|
||||||
|
break Poll::Ready(Err(e));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if self.closed {
|
|
||||||
// Stop if we're closed
|
|
||||||
break Poll::Ready(Ok(()));
|
|
||||||
} else if self.set_parent_waker(cx.waker()) {
|
} else if self.set_parent_waker(cx.waker()) {
|
||||||
// if we updated the stored waker, mark all as woken an try polling again
|
// if we updated the stored waker, mark all as woken an try polling again
|
||||||
// This doesn't actually "wake" the waker, it just allows the handle to be polled
|
// This doesn't actually "wake" the waker, it just allows the handle to be polled
|
||||||
|
|
Loading…
Reference in a new issue