Skip to content

Commit

Permalink
msg_controllen has type socklen_t in musl and ulibc arm
Browse files Browse the repository at this point in the history
  • Loading branch information
zonyitoo committed Mar 23, 2021
1 parent c6d70f3 commit 0b1630d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ fn recv_dest_from(socket: &UdpSocket, buf: &mut [u8]) -> io::Result<(usize, Sock
msg.msg_iovlen = 1;

msg.msg_control = control_buf.as_mut_ptr() as *mut _;
msg.msg_controllen = control_buf.len() as libc::size_t;
msg.msg_controllen = control_buf.len() as libc::socklen_t;

let fd = socket.as_raw_fd();
let ret = libc::recvmsg(fd, &mut msg, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::{
task::{Context, Poll},
};

use cfg_if::cfg_if;
use futures::{future::poll_fn, ready};
use socket2::{Domain, Protocol, SockAddr, Socket, Type};
use tokio::io::unix::AsyncFd;
Expand Down Expand Up @@ -232,7 +233,13 @@ fn recv_dest_from(socket: &UdpSocket, buf: &mut [u8]) -> io::Result<(usize, Sock
msg.msg_iovlen = 1;

msg.msg_control = control_buf.as_mut_ptr() as *mut _;
msg.msg_controllen = control_buf.len() as libc::size_t;
cfg_if! {
if #[cfg(any(target_env = "musl", all(target_env = "uclibc", target_arch = "arm")))] {
msg.msg_controllen = control_buf.len() as libc::socklen_t;
} else {
msg.msg_controllen = control_buf.len() as libc::size_t;
}
}

let fd = socket.as_raw_fd();
let ret = libc::recvmsg(fd, &mut msg, 0);
Expand Down

0 comments on commit 0b1630d

Please sign in to comment.