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
@ -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 New Issue
Block a user