Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(udp): pass SocketAddr instead of &SocketAddr #2169

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion neqo-bin/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ impl<'a, H: Handler> Runner<'a, H> {

async fn process_multiple_input(&mut self) -> Res<()> {
loop {
let dgrams = self.socket.recv(&self.local_addr)?;
let dgrams = self.socket.recv(self.local_addr)?;
if dgrams.is_empty() {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion neqo-bin/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ impl ServerRunner {
match self.ready().await? {
Ready::Socket(inx) => loop {
let (host, socket) = self.sockets.get_mut(inx).unwrap();
let dgrams = socket.recv(host)?;
let dgrams = socket.recv(*host)?;
if dgrams.is_empty() {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion neqo-bin/src/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Socket {

/// Receive a batch of [`Datagram`]s on the given [`Socket`], each set with
/// the provided local address.
pub fn recv(&self, local_address: &SocketAddr) -> Result<Vec<Datagram>, io::Error> {
pub fn recv(&self, local_address: SocketAddr) -> Result<Vec<Datagram>, io::Error> {
self.inner
.try_io(tokio::io::Interest::READABLE, || {
neqo_udp::recv_inner(local_address, &self.state, &self.inner)
Expand Down
12 changes: 6 additions & 6 deletions neqo-udp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use std::os::fd::AsFd as SocketRef;
use std::os::windows::io::AsSocket as SocketRef;

pub fn recv_inner(
local_address: &SocketAddr,
local_address: SocketAddr,
state: &UdpSocketState,
socket: impl SocketRef,
) -> Result<Vec<Datagram>, io::Error> {
Expand Down Expand Up @@ -99,7 +99,7 @@ pub fn recv_inner(
);
Datagram::new(
meta.addr,
*local_address,
local_address,
meta.ecn.map(|n| IpTos::from(n as u8)).unwrap_or_default(),
d,
)
Expand Down Expand Up @@ -138,7 +138,7 @@ impl<S: SocketRef> Socket<S> {

/// Receive a batch of [`Datagram`]s on the given [`Socket`], each
/// set with the provided local address.
pub fn recv(&self, local_address: &SocketAddr) -> Result<Vec<Datagram>, io::Error> {
pub fn recv(&self, local_address: SocketAddr) -> Result<Vec<Datagram>, io::Error> {
recv_inner(local_address, &self.state, &self.inner)
}
}
Expand Down Expand Up @@ -170,7 +170,7 @@ mod tests {
);

sender.send(&datagram)?;
let res = receiver.recv(&receiver_addr);
let res = receiver.recv(receiver_addr);
assert_eq!(res.unwrap_err().kind(), std::io::ErrorKind::WouldBlock);

Ok(())
Expand All @@ -192,7 +192,7 @@ mod tests {
sender.send(&datagram)?;

let received_datagram = receiver
.recv(&receiver_addr)
.recv(receiver_addr)
.expect("receive to succeed")
.into_iter()
.next()
Expand Down Expand Up @@ -238,7 +238,7 @@ mod tests {
let mut num_received = 0;
while num_received < max_gso_segments {
receiver
.recv(&receiver_addr)
.recv(receiver_addr)
.expect("receive to succeed")
.into_iter()
.for_each(|d| {
Expand Down
Loading