diff --git a/src/fd/socket/tcp.rs b/src/fd/socket/tcp.rs index f32838b9fe..2c09439d3e 100644 --- a/src/fd/socket/tcp.rs +++ b/src/fd/socket/tcp.rs @@ -213,8 +213,14 @@ impl ObjectInterface for Socket { let ret = event & available; if ret.is_empty() { - socket.register_recv_waker(cx.waker()); - socket.register_send_waker(cx.waker()); + if event.intersects(PollEvent::POLLIN | PollEvent::POLLRDNORM | PollEvent::POLLRDBAND) { + socket.register_recv_waker(cx.waker()); + } + + if event.intersects(PollEvent::POLLOUT | PollEvent::POLLWRNORM | PollEvent::POLLWRBAND) { + socket.register_send_waker(cx.waker()); + } + Poll::Pending } else { Poll::Ready(Ok(ret)) diff --git a/src/fd/socket/udp.rs b/src/fd/socket/udp.rs index 667df463e9..3d507a1724 100644 --- a/src/fd/socket/udp.rs +++ b/src/fd/socket/udp.rs @@ -142,8 +142,14 @@ impl ObjectInterface for Socket { }; if ret.is_empty() { - socket.register_recv_waker(cx.waker()); - socket.register_send_waker(cx.waker()); + if event.intersects(PollEvent::POLLIN | PollEvent::POLLRDNORM | PollEvent::POLLRDBAND) { + socket.register_recv_waker(cx.waker()); + } + + if event.intersects(PollEvent::POLLOUT | PollEvent::POLLWRNORM | PollEvent::POLLWRBAND) { + socket.register_send_waker(cx.waker()); + } + Poll::Pending } else { Poll::Ready(Ok(ret))