diff --git a/libasync/src/smoltcp/tcp_stream.rs b/libasync/src/smoltcp/tcp_stream.rs index 4fed9ef..7fa176f 100644 --- a/libasync/src/smoltcp/tcp_stream.rs +++ b/libasync/src/smoltcp/tcp_stream.rs @@ -141,12 +141,18 @@ impl TcpStream { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let result = self.stream.with_socket(|mut socket| { - socket.recv(|buf| match (self.f)(buf) { - Poll::Ready((amount, result)) => - (amount, Poll::Ready(Ok(result))), - Poll::Pending => - // 0 bytes consumed - (0, Poll::Pending), + socket.recv(|buf| { + if buf.len() > 0 { + match (self.f)(buf) { + Poll::Ready((amount, result)) => + (amount, Poll::Ready(Ok(result))), + Poll::Pending => + // 0 bytes consumed + (0, Poll::Pending), + } + } else { + (0, Poll::Pending) + } }) }); match result {