diff --git a/src/fd/socket/tcp.rs b/src/fd/socket/tcp.rs index dc3634f1ce..63a69eeaac 100644 --- a/src/fd/socket/tcp.rs +++ b/src/fd/socket/tcp.rs @@ -208,7 +208,9 @@ impl ObjectInterface for Socket { Poll::Pending } _ => { - if socket.may_recv() && self.listen.swap(false, Ordering::Relaxed) { + if socket.can_recv() + || socket.may_recv() && self.listen.swap(false, Ordering::Relaxed) + { // In case, we just establish a fresh connection in non-blocking mode, we try to read data. if event.contains(PollEvent::POLLIN) { ret.insert(PollEvent::POLLIN); @@ -233,18 +235,6 @@ impl ObjectInterface for Socket { } } - if socket.can_recv() { - if event.contains(PollEvent::POLLIN) { - ret.insert(PollEvent::POLLIN); - } - if event.contains(PollEvent::POLLRDNORM) { - ret.insert(PollEvent::POLLRDNORM); - } - if event.contains(PollEvent::POLLRDBAND) { - ret.insert(PollEvent::POLLRDBAND); - } - } - if ret.is_empty() { socket.register_recv_waker(cx.waker()); socket.register_send_waker(cx.waker());