From 15dd43d8713a24295e160a8368797b46d7398104 Mon Sep 17 00:00:00 2001 From: Tuetuopay Date: Thu, 8 Feb 2024 19:38:13 +0100 Subject: [PATCH] unix: fix recv_multiple_from on 32-bit android For some braindead reason, old versions of android on 32 bit defined socklen_t to be an int, instead of the unsigned int it was everywhere else. --- src/sys/unix.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/sys/unix.rs b/src/sys/unix.rs index 148e2c9d..8c3a3ee4 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -1099,7 +1099,21 @@ pub(crate) fn recv_multiple_from( flags: c_int, ) -> io::Result> { let mut addrs = (0..msgs.len()) - .map(|_| unsafe { SockAddr::new(mem::zeroed(), mem::size_of::() as u32) }) + .map(|_| unsafe { + SockAddr::new(mem::zeroed(), { + #[cfg(all(target_os = "android", any(target_arch = "arm", target_arch = "x86")))] + { + mem::size_of::() as i32 + } + #[cfg(not(all( + target_os = "android", + any(target_arch = "arm", target_arch = "x86") + )))] + { + mem::size_of::() as u32 + } + }) + }) .collect::>(); let mut msgs = MmsgHdrMut::new(msgs.len()) .with_buffers(msgs)