Skip to content

Commit

Permalink
fix(udp): feature flag tracing in windows.rs
Browse files Browse the repository at this point in the history
8712910 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`.
  • Loading branch information
mxinden committed Jul 22, 2024
1 parent ff91ffe commit b010adf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion quinn-udp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
16 changes: 12 additions & 4 deletions quinn-udp/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -387,7 +392,8 @@ const OPTION_ON: u32 = 1;
static WSARECVMSG_PTR: Lazy<WinSock::LPFN_WSARECVMSG> = 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()
);
Expand Down Expand Up @@ -416,12 +422,14 @@ static WSARECVMSG_PTR: Lazy<WinSock::LPFN_WSARECVMSG> = 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::<WinSock::LPFN_WSARECVMSG>() {
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;
}

Expand Down

0 comments on commit b010adf

Please sign in to comment.