From 0da021f1eedb0d2f4ed4ac36e04a514ea1efe6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 14 Feb 2024 16:52:30 +0100 Subject: [PATCH] refactor(PollEvent): collapse if statements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- src/fd/socket/tcp.rs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) 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());