Merge pull request #251 from embassy-rs/net-fix
net/tcp: Fix panic when consuming 0 bytes at EOF
This commit is contained in:
commit
06d69a8028
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) {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue