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

Fix compile error: Make IOV live longer #163

Merged
merged 12 commits into from
Sep 13, 2023
23 changes: 11 additions & 12 deletions src/adapters/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ impl Remote for RemoteResource {
}
Err(ref err) if err.kind() == ErrorKind::ConnectionRefused => {
// Avoid ICMP generated error to be logged
break ReadStatus::WaitNextEvent
break ReadStatus::WaitNextEvent;
lemunozm marked this conversation as resolved.
Show resolved Hide resolved
}
Err(err) => {
log::error!("UDP receive error: {}", err);
break ReadStatus::WaitNextEvent // Should not happen
break ReadStatus::WaitNextEvent; // Should not happen
lemunozm marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down Expand Up @@ -236,9 +236,10 @@ impl LocalResource {
let mut control_buffer = nix::cmsg_space!(libc::sockaddr_storage);

loop {
let mut iov = [io::IoSliceMut::new(&mut input_buffer)];
let result = socket::recvmsg::<SockaddrStorage>(
self.socket.as_raw_fd(),
&mut [io::IoSliceMut::new(&mut input_buffer)],
&mut iov,
Some(&mut control_buffer),
MsgFlags::empty(),
);
Expand All @@ -261,15 +262,15 @@ impl LocalResource {
};

if !ingress_addresses.contains(&ingress_ip) {
continue
continue;
lemunozm marked this conversation as resolved.
Show resolved Hide resolved
}

fn convert_sockaddr(addr: SockaddrStorage) -> Option<SocketAddr> {
if let Some(addr) = addr.as_sockaddr_in() {
return Some(SocketAddr::V4((*addr).into()))
return Some(SocketAddr::V4((*addr).into()));
lemunozm marked this conversation as resolved.
Show resolved Hide resolved
}
if let Some(addr) = addr.as_sockaddr_in6() {
return Some(SocketAddr::V6((*addr).into()))
return Some(SocketAddr::V6((*addr).into()));
lemunozm marked this conversation as resolved.
Show resolved Hide resolved
}
None
}
Expand Down Expand Up @@ -385,16 +386,14 @@ impl Local for LocalResource {
Some(ingress_addresses)
}
}
}
else {
} else {
lemunozm marked this conversation as resolved.
Show resolved Hide resolved
None
};

if let Some(multicast) = multicast {
socket.join_multicast_v4(multicast.ip(), &Ipv4Addr::UNSPECIFIED)?;
socket.bind(&SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, addr.port()).into())?;
}
else {
} else {
lemunozm marked this conversation as resolved.
Show resolved Hide resolved
socket.bind(&addr.into())?;
}

Expand All @@ -416,7 +415,7 @@ impl Local for LocalResource {
#[cfg(target_os = "linux")]
if let Some(ingress_addresses) = &self.ingress_addresses {
self.accept_filtered(ingress_addresses, accept_remote);
return
return;
lemunozm marked this conversation as resolved.
Show resolved Hide resolved
}

let buffer: MaybeUninit<[u8; MAX_LOCAL_PAYLOAD_LEN]> = MaybeUninit::uninit();
Expand Down Expand Up @@ -463,7 +462,7 @@ fn send_packet(data: &[u8], send_method: impl Fn(&[u8]) -> io::Result<usize>) ->
}
Err(err) => {
log::error!("UDP send error: {}", err);
break SendStatus::ResourceNotFound // should not happen
break SendStatus::ResourceNotFound; // should not happen
lemunozm marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down