From 2bb97db5e149260a09180e53195dc4c79db9c206 Mon Sep 17 00:00:00 2001 From: "masa.koz" Date: Mon, 28 Mar 2022 18:06:47 +0900 Subject: [PATCH] net: make `try_io` methods call mio's `try_io` internally (#4582) --- tokio/Cargo.toml | 2 +- tokio/src/net/tcp/stream.rs | 4 +++- tokio/src/net/udp.rs | 4 +++- tokio/src/net/unix/datagram/socket.rs | 4 +++- tokio/src/net/unix/stream.rs | 4 +++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index ba165d2556c..90a32d98164 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -97,7 +97,7 @@ pin-project-lite = "0.2.0" bytes = { version = "1.0.0", optional = true } once_cell = { version = "1.5.2", optional = true } memchr = { version = "2.2", optional = true } -mio = { version = "0.8.0", optional = true } +mio = { version = "0.8.1", optional = true } socket2 = { version = "0.4.4", optional = true, features = [ "all" ] } num_cpus = { version = "1.8.0", optional = true } parking_lot = { version = "0.12.0", optional = true } diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs index ebb67b84d16..5228e1bc242 100644 --- a/tokio/src/net/tcp/stream.rs +++ b/tokio/src/net/tcp/stream.rs @@ -968,7 +968,9 @@ impl TcpStream { interest: Interest, f: impl FnOnce() -> io::Result, ) -> io::Result { - 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 diff --git a/tokio/src/net/udp.rs b/tokio/src/net/udp.rs index 12af5152c28..eea6164b177 100644 --- a/tokio/src/net/udp.rs +++ b/tokio/src/net/udp.rs @@ -1272,7 +1272,9 @@ impl UdpSocket { interest: Interest, f: impl FnOnce() -> io::Result, ) -> io::Result { - 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. diff --git a/tokio/src/net/unix/datagram/socket.rs b/tokio/src/net/unix/datagram/socket.rs index d5b618663dc..def006c4761 100644 --- a/tokio/src/net/unix/datagram/socket.rs +++ b/tokio/src/net/unix/datagram/socket.rs @@ -1241,7 +1241,9 @@ impl UnixDatagram { interest: Interest, f: impl FnOnce() -> io::Result, ) -> io::Result { - 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. diff --git a/tokio/src/net/unix/stream.rs b/tokio/src/net/unix/stream.rs index 4e7ef87b416..fe2d825bf98 100644 --- a/tokio/src/net/unix/stream.rs +++ b/tokio/src/net/unix/stream.rs @@ -685,7 +685,9 @@ impl UnixStream { interest: Interest, f: impl FnOnce() -> io::Result, ) -> io::Result { - 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`.