From ac2985e4e0e423f0be1038ef81086f7ae0beb6e0 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Fri, 10 Jan 2025 10:13:24 +0100 Subject: [PATCH] tests(udp): use blocking socket to receive empty datagram (#2339) The `handle_empty_datagram` unit tests sends and receives an empty datagram. To prevent a race condition where the receiver tries to receive the datagram before it is available (error `WouldBlock`), use a blocking socket via `socket()` instead. --- neqo-udp/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neqo-udp/src/lib.rs b/neqo-udp/src/lib.rs index ef57a996f8..a68367aa8f 100644 --- a/neqo-udp/src/lib.rs +++ b/neqo-udp/src/lib.rs @@ -233,7 +233,7 @@ mod tests { // platforms. Use `std` socket instead. See also // . let sender = std::net::UdpSocket::bind("127.0.0.1:0")?; - let receiver = Socket::new(std::net::UdpSocket::bind("127.0.0.1:0")?)?; + let receiver = socket()?; let receiver_addr: SocketAddr = "127.0.0.1:0".parse().unwrap(); sender.send_to(&[], receiver.inner.local_addr()?)?;