From 1ac10ba0d4bb625c67fd897c22462608a4c24fba Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 14 Apr 2020 09:03:48 +0800 Subject: [PATCH] Revert "libasync: don't let TcpStream::read() call back for empty buffers" Usually easy to handle in user code and avoids duplicating logic. This reverts commit e3a6a6e1f80ec27f5f96a0333ada9f71f55ac987. --- libasync/src/smoltcp/tcp_stream.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/libasync/src/smoltcp/tcp_stream.rs b/libasync/src/smoltcp/tcp_stream.rs index 7fa176f..4fed9ef 100644 --- a/libasync/src/smoltcp/tcp_stream.rs +++ b/libasync/src/smoltcp/tcp_stream.rs @@ -141,18 +141,12 @@ impl TcpStream { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let result = self.stream.with_socket(|mut socket| { - 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) - } + socket.recv(|buf| match (self.f)(buf) { + Poll::Ready((amount, result)) => + (amount, Poll::Ready(Ok(result))), + Poll::Pending => + // 0 bytes consumed + (0, Poll::Pending), }) }); match result {