From b010adf47e65f0814282ab4e9f81d17389feefea Mon Sep 17 00:00:00 2001 From: Max Inden Date: Mon, 22 Jul 2024 20:44:34 +0200 Subject: [PATCH] fix(udp): feature flag tracing in windows.rs 8712910a made `tracing` optional and added optional `log`, but forgot to update `quinn-udp/src/windows.rs`. This commit fixes the oversight and bumps the `quinn-udp` version to `v0.5.4`. --- quinn-udp/Cargo.toml | 2 +- quinn-udp/src/windows.rs | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/quinn-udp/Cargo.toml b/quinn-udp/Cargo.toml index 333b1aeaa..1bf34684f 100644 --- a/quinn-udp/Cargo.toml +++ b/quinn-udp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "quinn-udp" -version = "0.5.3" +version = "0.5.4" edition = "2021" rust-version = "1.66" license = "MIT OR Apache-2.0" diff --git a/quinn-udp/src/windows.rs b/quinn-udp/src/windows.rs index 25cdadb12..475a71657 100644 --- a/quinn-udp/src/windows.rs +++ b/quinn-udp/src/windows.rs @@ -9,7 +9,11 @@ use std::{ }; use libc::{c_int, c_uint}; +#[cfg(all(feature = "direct-log", not(feature = "tracing")))] +use log::{debug, error}; use once_cell::sync::Lazy; +#[cfg(feature = "tracing")] +use tracing::{debug, error}; use windows_sys::Win32::Networking::WinSock; use crate::{ @@ -60,7 +64,8 @@ impl UdpSocketState { // We don't support old versions of Windows that do not enable access to `WSARecvMsg()` if WSARECVMSG_PTR.is_none() { - tracing::error!("network stack does not support WSARecvMsg function"); + #[cfg(any(feature = "tracing", feature = "direct-log"))] + error!("network stack does not support WSARecvMsg function"); return Err(io::Error::from(io::ErrorKind::Unsupported)); } @@ -387,7 +392,8 @@ const OPTION_ON: u32 = 1; static WSARECVMSG_PTR: Lazy = Lazy::new(|| { let s = unsafe { WinSock::socket(WinSock::AF_INET as _, WinSock::SOCK_DGRAM as _, 0) }; if s == WinSock::INVALID_SOCKET { - tracing::debug!( + #[cfg(any(feature = "tracing", feature = "direct-log"))] + debug!( "ignoring WSARecvMsg function pointer due to socket creation error: {}", io::Error::last_os_error() ); @@ -416,12 +422,14 @@ static WSARECVMSG_PTR: Lazy = Lazy::new(|| { }; if rc == -1 { - tracing::debug!( + #[cfg(any(feature = "tracing", feature = "direct-log"))] + debug!( "ignoring WSARecvMsg function pointer due to ioctl error: {}", io::Error::last_os_error() ); } else if len as usize != mem::size_of::() { - tracing::debug!("ignoring WSARecvMsg function pointer due to pointer size mismatch"); + #[cfg(any(feature = "tracing", feature = "direct-log"))] + debug!("ignoring WSARecvMsg function pointer due to pointer size mismatch"); wsa_recvmsg_ptr = None; }