net/tcp: Fix panic when consuming 0 bytes at EOF

This commit is contained in:
Dario Nieuwenhuis 2021-06-18 01:58:14 +02:00
parent 0d1ae0a01e
commit d94feb9fcd

View file

@ -151,6 +151,11 @@ impl<'a> AsyncBufRead for TcpSocket<'a> {
}
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()
}
}