Skip to content

Commit

Permalink
tests(udp): use blocking socket to receive empty datagram (#2339)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mxinden authored Jan 10, 2025
1 parent c9f5a36 commit ac2985e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion neqo-udp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ mod tests {
// platforms. Use `std` socket instead. See also
// <https://github.com/quinn-rs/quinn/pull/2123>.
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()?)?;
Expand Down

0 comments on commit ac2985e

Please sign in to comment.