From 07222809c0d1218950ff5b08cf45159d796430af Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Wed, 20 Dec 2023 18:48:36 -0800 Subject: [PATCH] Fix bitrotted fallback UDP backend `UdpState` was removed some time ago, and various other interface details have changed. As a result, the build would fail on platforms without native support. --- quinn-udp/src/fallback.rs | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/quinn-udp/src/fallback.rs b/quinn-udp/src/fallback.rs index 6cba4f069..4e8d608c4 100644 --- a/quinn-udp/src/fallback.rs +++ b/quinn-udp/src/fallback.rs @@ -4,9 +4,7 @@ use std::{ time::Instant, }; -use proto::Transmit; - -use super::{log_sendmsg_error, RecvMeta, UdpSockRef, UdpState, IO_ERROR_LOG_INTERVAL}; +use super::{log_sendmsg_error, RecvMeta, Transmit, UdpSockRef, IO_ERROR_LOG_INTERVAL}; /// Fallback UDP socket interface that stubs out all special functionality /// @@ -18,20 +16,15 @@ pub struct UdpSocketState { } impl UdpSocketState { - pub fn new(socket: UdpSocketRef<'_>) -> io::Result { + pub fn new(socket: UdpSockRef<'_>) -> io::Result { socket.0.set_nonblocking(true)?; let now = Instant::now(); - Self { + Ok(Self { last_send_error: Mutex::new(now.checked_sub(2 * IO_ERROR_LOG_INTERVAL).unwrap_or(now)), - } + }) } - pub fn send( - &self, - socket: UdpSockRef<'_>, - _state: &UdpState, - transmits: &[Transmit], - ) -> io::Result { + pub fn send(&self, socket: UdpSockRef<'_>, transmits: &[Transmit]) -> io::Result { let mut sent = 0; for transmit in transmits { match socket.0.send_to( @@ -97,25 +90,11 @@ impl UdpSocketState { pub fn gro_segments(&self) -> usize { 1 } -} - -impl Default for UdpSocketState { - fn default() -> Self { - Self::new() - } -} -/// Returns the platforms UDP socket capabilities -pub(crate) fn udp_state() -> super::UdpState { - super::UdpState { - max_gso_segments: std::sync::atomic::AtomicUsize::new(1), - gro_segments: 1, + #[inline] + pub fn may_fragment(&self) -> bool { + true } } -#[inline] -pub(crate) fn may_fragment() -> bool { - true -} - pub(crate) const BATCH_SIZE: usize = 1;