Skip to content

Commit

Permalink
ErrorKind::Interrupted should be handled by discard_exact.
Browse files Browse the repository at this point in the history
  • Loading branch information
kamadak committed Sep 6, 2020
1 parent 4b18cbf commit 7c11330
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ pub trait BufReadExt {
impl<T> BufReadExt for T where T: io::BufRead {
fn discard_exact(&mut self, mut len: usize) -> io::Result<()> {
while len > 0 {
let consume_len = self.fill_buf()?.len().min(len);
let consume_len = match self.fill_buf() {
Ok(buf) => buf.len().min(len),
Err(e) if e.kind() == io::ErrorKind::Interrupted => continue,
Err(e) => return Err(e),
};
self.consume(consume_len);
len -= consume_len;
}
Expand Down

0 comments on commit 7c11330

Please # to comment.