forked from M-Labs/zynq-rs
Revert "Revert "libasync: don't let TcpStream::read() call back for empty buffers""
Zero-length buffer is really a special case, as one must return Poll::Pending in this case.
This reverts commit 1ac10ba0d4
.
This commit is contained in:
parent
1ac10ba0d4
commit
be35be8d38
|
@ -141,12 +141,18 @@ 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| match (self.f)(buf) {
|
socket.recv(|buf| {
|
||||||
|
if buf.len() > 0 {
|
||||||
|
match (self.f)(buf) {
|
||||||
Poll::Ready((amount, result)) =>
|
Poll::Ready((amount, result)) =>
|
||||||
(amount, Poll::Ready(Ok(result))),
|
(amount, Poll::Ready(Ok(result))),
|
||||||
Poll::Pending =>
|
Poll::Pending =>
|
||||||
// 0 bytes consumed
|
// 0 bytes consumed
|
||||||
(0, Poll::Pending),
|
(0, Poll::Pending),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
(0, Poll::Pending)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
match result {
|
match result {
|
||||||
|
|
Loading…
Reference in New Issue