libasync: don't let TcpStream::read() call back for empty buffers
This commit is contained in:
parent
60a29456ec
commit
e3a6a6e1f8
|
@ -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| {
|
||||||
Poll::Ready((amount, result)) =>
|
if buf.len() > 0 {
|
||||||
(amount, Poll::Ready(Ok(result))),
|
match (self.f)(buf) {
|
||||||
Poll::Pending =>
|
Poll::Ready((amount, result)) =>
|
||||||
// 0 bytes consumed
|
(amount, Poll::Ready(Ok(result))),
|
||||||
(0, Poll::Pending),
|
Poll::Pending =>
|
||||||
|
// 0 bytes consumed
|
||||||
|
(0, Poll::Pending),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
(0, Poll::Pending)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
match result {
|
match result {
|
||||||
|
|
Loading…
Reference in New Issue