From 7b72b71c2fcab6bfa3609b5971df116a67e63a84 Mon Sep 17 00:00:00 2001 From: JieLiang Ma Date: Mon, 14 Aug 2023 19:18:32 +0800 Subject: [PATCH] Move function may_fragment() from lib quinn-udp to UdpSocketState. --- quinn-udp/src/lib.rs | 8 -------- quinn-udp/src/unix.rs | 13 ++++++++----- quinn-udp/src/windows.rs | 10 +++++----- quinn/src/runtime/async_std.rs | 2 +- quinn/src/runtime/tokio.rs | 2 +- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/quinn-udp/src/lib.rs b/quinn-udp/src/lib.rs index c26affdb5..cbbae2cde 100644 --- a/quinn-udp/src/lib.rs +++ b/quinn-udp/src/lib.rs @@ -32,14 +32,6 @@ mod imp; pub use imp::UdpSocketState; -/// Whether transmitted datagrams might get fragmented by the IP layer -/// -/// Returns `false` on targets which employ e.g. the `IPV6_DONTFRAG` socket option. -#[inline] -pub fn may_fragment() -> bool { - imp::may_fragment() -} - /// Number of UDP packets to send/receive at a time pub const BATCH_SIZE: usize = imp::BATCH_SIZE; diff --git a/quinn-udp/src/unix.rs b/quinn-udp/src/unix.rs index 92548dd17..87e0b5198 100644 --- a/quinn-udp/src/unix.rs +++ b/quinn-udp/src/unix.rs @@ -165,6 +165,14 @@ impl UdpSocketState { self.gro_segments } + /// Whether transmitted datagrams might get fragmented by the IP layer + /// + /// Returns `false` on targets which employ e.g. the `IPV6_DONTFRAG` socket option. + #[inline] + pub fn may_fragment(&self) -> bool { + false + } + /// Returns true if we previously got an EINVAL error from `sendmsg` or `sendmmsg` syscall. fn sendmsg_einval(&self) -> bool { self.sendmsg_einval.load(Ordering::Relaxed) @@ -713,11 +721,6 @@ pub(crate) const BATCH_SIZE: usize = 32; #[cfg(any(target_os = "macos", target_os = "ios"))] pub(crate) const BATCH_SIZE: usize = 1; -#[inline] -pub(crate) fn may_fragment() -> bool { - false -} - #[cfg(target_os = "linux")] mod gso { use super::*; diff --git a/quinn-udp/src/windows.rs b/quinn-udp/src/windows.rs index 5e2dfeb8b..4680d1a45 100644 --- a/quinn-udp/src/windows.rs +++ b/quinn-udp/src/windows.rs @@ -147,11 +147,11 @@ impl UdpSocketState { pub fn gro_segments(&self) -> usize { 1 } + + #[inline] + pub fn may_fragment(&self) -> bool { + false + } } pub(crate) const BATCH_SIZE: usize = 1; - -#[inline] -pub(crate) fn may_fragment() -> bool { - false -} diff --git a/quinn/src/runtime/async_std.rs b/quinn/src/runtime/async_std.rs index 5ac90c1b9..ddff8fef1 100644 --- a/quinn/src/runtime/async_std.rs +++ b/quinn/src/runtime/async_std.rs @@ -77,7 +77,7 @@ impl AsyncUdpSocket for UdpSocket { } fn may_fragment(&self) -> bool { - udp::may_fragment() + self.inner.may_fragment() } fn max_transmit_segments(&self) -> usize { diff --git a/quinn/src/runtime/tokio.rs b/quinn/src/runtime/tokio.rs index b31bff795..90a5c865d 100644 --- a/quinn/src/runtime/tokio.rs +++ b/quinn/src/runtime/tokio.rs @@ -83,7 +83,7 @@ impl AsyncUdpSocket for UdpSocket { } fn may_fragment(&self) -> bool { - udp::may_fragment() + self.inner.may_fragment() } fn max_transmit_segments(&self) -> usize {