diff --git a/Cargo.lock b/Cargo.lock index 5e7bac8..417a77c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -962,8 +962,7 @@ dependencies = [ [[package]] name = "iroh-quinn-udp" version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83130fe88846cf7afedb9477b24120a64310cadaf6f90c6bc9def19d7c283605" +source = "git+https://github.com/n0-computer/quinn?branch=main#9a29a461e801130a110c0df26a2248a6c61c7535" dependencies = [ "cfg_aliases", "libc", diff --git a/Cargo.toml b/Cargo.toml index 208c81e..9e6d1ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,3 +37,6 @@ unexpected_cfgs = { level = "warn", check-cfg = ["cfg(iroh_docsrs)"] } [workspace.lints.clippy] unused-async = "warn" + +[patch.crates-io] +iroh-quinn-udp = { git = "https://github.com/n0-computer/quinn", branch = "main" } diff --git a/deny.toml b/deny.toml index a78fd16..f71c9de 100644 --- a/deny.toml +++ b/deny.toml @@ -23,3 +23,8 @@ ignore = [ "RUSTSEC-2024-0436", # paste unmaintained "RUSTSEC-2023-0089", # atomic-polyfill unmaintained ] + +[sources] +allow-git = [ + "https://github.com/n0-computer/quinn" +] diff --git a/netwatch/src/udp.rs b/netwatch/src/udp.rs index 2a609ed..e0bcc96 100644 --- a/netwatch/src/udp.rs +++ b/netwatch/src/udp.rs @@ -2,6 +2,7 @@ use std::{ future::Future, io, net::SocketAddr, + num::NonZeroUsize, pin::Pin, sync::{Arc, RwLock, RwLockReadGuard, TryLockError, atomic::AtomicBool}, task::{Context, Poll}, @@ -463,7 +464,7 @@ impl UdpSocket { /// /// This is 1 if the platform doesn't support GSO. Subject to change if errors are detected /// while using GSO. - pub fn max_gso_segments(&self) -> usize { + pub fn max_gso_segments(&self) -> NonZeroUsize { let guard = self.socket.read().unwrap(); guard.max_gso_segments() } @@ -472,7 +473,7 @@ impl UdpSocket { /// compute the receive buffer size. /// /// Returns 1 if the platform doesn't support GRO. - pub fn gro_segments(&self) -> usize { + pub fn gro_segments(&self) -> NonZeroUsize { let guard = self.socket.read().unwrap(); guard.gro_segments() } @@ -687,8 +688,8 @@ enum SocketState { addr: SocketAddr, }, Closed { - last_max_gso_segments: usize, - last_gro_segments: usize, + last_max_gso_segments: NonZeroUsize, + last_gro_segments: NonZeroUsize, last_may_fragment: bool, }, } @@ -818,7 +819,7 @@ impl SocketState { } } - fn max_gso_segments(&self) -> usize { + fn max_gso_segments(&self) -> NonZeroUsize { match self { Self::Connected { state, .. } => state.max_gso_segments(), Self::Closed { @@ -828,7 +829,7 @@ impl SocketState { } } - fn gro_segments(&self) -> usize { + fn gro_segments(&self) -> NonZeroUsize { match self { Self::Connected { state, .. } => state.gro_segments(), Self::Closed { @@ -840,7 +841,6 @@ impl SocketState { impl Drop for UdpSocket { fn drop(&mut self) { - trace!("dropping UdpSocket"); if let Some((socket, _)) = self.socket.write().unwrap().close() { if let Ok(handle) = tokio::runtime::Handle::try_current() { // No wakeup after dropping write lock here, since we're getting dropped.