forked from M-Labs/zynq-rs
1
0
Fork 0

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 e3a6a6e1f8.
This commit is contained in:
Sebastien Bourdeauducq 2020-04-14 09:03:48 +08:00
parent e3a6a6e1f8
commit 1ac10ba0d4
1 changed files with 6 additions and 12 deletions

View File

@ -141,18 +141,12 @@ impl TcpStream {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let result = self.stream.with_socket(|mut socket| { let result = self.stream.with_socket(|mut socket| {
socket.recv(|buf| { socket.recv(|buf| match (self.f)(buf) {
if buf.len() > 0 { Poll::Ready((amount, result)) =>
match (self.f)(buf) { (amount, Poll::Ready(Ok(result))),
Poll::Ready((amount, result)) => Poll::Pending =>
(amount, Poll::Ready(Ok(result))), // 0 bytes consumed
Poll::Pending => (0, Poll::Pending),
// 0 bytes consumed
(0, Poll::Pending),
}
} else {
(0, Poll::Pending)
}
}) })
}); });
match result { match result {