ErrorKind::Interrupted should be handled by discard_exact.

This commit is contained in:
KAMADA Ken'ichi 2020-09-06 15:23:36 +09:00
parent 4b18cbfe92
commit 7c113302de
1 changed files with 5 additions and 1 deletions

View File

@ -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;
}