Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enumset = { version = "1.1", default-features = false }
hex = { version = "0.4", default-features = false }
log = { version = "0.4", default-features = false }
qlog = { version = "0.15", default-features = false }
quinn-udp = { version = "0.5.10", default-features = false, features = ["direct-log", "fast-apple-datapath"] }
quinn-udp = { version = "0.5.11", default-features = false, features = ["direct-log", "fast-apple-datapath"] }
regex = { version = "1.9", default-features = false }
static_assertions = { version = "1.1", default-features = false }
strum = { version = "0.26", default-features = false, features = ["derive"] }
Expand Down
22 changes: 20 additions & 2 deletions neqo-bin/src/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use std::{io, net::SocketAddr};

use neqo_common::Datagram;
use neqo_common::{qdebug, Datagram};
use neqo_udp::{DatagramIter, RecvBuf};

/// Ideally this would live in [`neqo-udp`]. [`neqo-udp`] is used in Firefox.
Expand All @@ -26,10 +26,28 @@ pub struct Socket {
impl Socket {
/// Create a new [`Socket`] bound to the provided address, not managed externally.
pub fn bind<A: std::net::ToSocketAddrs>(addr: A) -> Result<Self, io::Error> {
const ONE_MB: usize = 1 << 20;
let socket = std::net::UdpSocket::bind(addr)?;
let state = quinn_udp::UdpSocketState::new((&socket).into())?;

let send_buf = state.send_buffer_size((&socket).into())?;
if send_buf < ONE_MB {
qdebug!("Increasing send buffer size from {send_buf} to {ONE_MB}");
state.set_send_buffer_size((&socket).into(), ONE_MB)?;
Comment thread
larseggert marked this conversation as resolved.
Outdated
} else {
qdebug!("Default send buffer size is {send_buf}, not changing");
}

let recv_buf = state.recv_buffer_size((&socket).into())?;
if recv_buf < ONE_MB {
qdebug!("Increasing receive buffer size from {recv_buf} to {ONE_MB}");
state.set_recv_buffer_size((&socket).into(), ONE_MB)?;
Comment thread
larseggert marked this conversation as resolved.
Comment thread
larseggert marked this conversation as resolved.
} else {
qdebug!("Default receive buffer size is {recv_buf}, not changing");
}

Comment thread
larseggert marked this conversation as resolved.
Ok(Self {
state: quinn_udp::UdpSocketState::new((&socket).into())?,
state,
inner: tokio::net::UdpSocket::from_std(socket)?,
})
}
Expand Down