ErrorKind::Interrupted should be handled by discard_exact.
This commit is contained in:
parent
4b18cbfe92
commit
7c113302de
|
@ -55,7 +55,11 @@ pub trait BufReadExt {
|
||||||
impl<T> BufReadExt for T where T: io::BufRead {
|
impl<T> BufReadExt for T where T: io::BufRead {
|
||||||
fn discard_exact(&mut self, mut len: usize) -> io::Result<()> {
|
fn discard_exact(&mut self, mut len: usize) -> io::Result<()> {
|
||||||
while len > 0 {
|
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);
|
self.consume(consume_len);
|
||||||
len -= consume_len;
|
len -= consume_len;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue