Skip to content

Commit

Permalink
tokio: make try_io methods call mio's try_io internally
Browse files Browse the repository at this point in the history
A user defined I/O closure should be called by mio's try_io to ensure
that the I/O receives more events if it hits a WouldBlock error.

Fixes: #4510
  • Loading branch information
masa-koz committed Mar 26, 2022
1 parent 121769c commit eacd282
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tokio/src/net/tcp/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ impl TcpStream {
interest: Interest,
f: impl FnOnce() -> io::Result<R>,
) -> io::Result<R> {
self.io.registration().try_io(interest, f)
self.io.registration().try_io(interest, || self.io.try_io(f))
}

/// Receives data on the socket from the remote address to which it is
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ impl UdpSocket {
interest: Interest,
f: impl FnOnce() -> io::Result<R>,
) -> io::Result<R> {
self.io.registration().try_io(interest, f)
self.io.registration().try_io(interest, || self.io.try_io(f))
}

/// Receives data from the socket, without removing it from the input queue.
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/net/unix/datagram/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ impl UnixDatagram {
interest: Interest,
f: impl FnOnce() -> io::Result<R>,
) -> io::Result<R> {
self.io.registration().try_io(interest, f)
self.io.registration().try_io(interest, || self.io.try_io(f))
}

/// Returns the local address that this socket is bound to.
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/net/unix/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ impl UnixStream {
interest: Interest,
f: impl FnOnce() -> io::Result<R>,
) -> io::Result<R> {
self.io.registration().try_io(interest, f)
self.io.registration().try_io(interest, || self.io.try_io(f))
}

/// Creates new `UnixStream` from a `std::os::unix::net::UnixStream`.
Expand Down

0 comments on commit eacd282

Please sign in to comment.