Skip to content

Commit

Permalink
register waker only if poll will wait for it
Browse files Browse the repository at this point in the history
  • Loading branch information
stlankes committed Feb 27, 2024
1 parent 661faa9 commit 8c2d400
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/fd/socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
10 changes: 8 additions & 2 deletions src/fd/socket/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 8c2d400

Please sign in to comment.