net/tcp: Fix panic when consuming 0 bytes at EOF
This commit is contained in:
parent
0d1ae0a01e
commit
d94feb9fcd
1 changed files with 5 additions and 0 deletions
|
@ -151,6 +151,11 @@ impl<'a> AsyncBufRead for TcpSocket<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn consume(self: Pin<&mut Self>, amt: usize) {
|
fn consume(self: Pin<&mut Self>, amt: usize) {
|
||||||
|
if amt == 0 {
|
||||||
|
// smoltcp's recv returns Finished if we're at EOF,
|
||||||
|
// even if we're "reading" 0 bytes.
|
||||||
|
return;
|
||||||
|
}
|
||||||
self.with(|s| s.recv(|_| (amt, ()))).unwrap()
|
self.with(|s| s.recv(|_| (amt, ()))).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue