diff options
Diffstat (limited to 'src/sys/unix/uds/listener.rs')
-rw-r--r-- | src/sys/unix/uds/listener.rs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/sys/unix/uds/listener.rs b/src/sys/unix/uds/listener.rs index b8fb5a9..547ff57 100644 --- a/src/sys/unix/uds/listener.rs +++ b/src/sys/unix/uds/listener.rs @@ -42,7 +42,13 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "solaris" + target_os = "solaris", + // Android x86's seccomp profile forbids calls to `accept4(2)` + // See https://github.com/tokio-rs/mio/issues/1445 for details + all( + target_arch = "x86", + target_os = "android" + ) )))] let socket = { let flags = libc::SOCK_NONBLOCK | libc::SOCK_CLOEXEC; @@ -59,7 +65,11 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "solaris" + target_os = "solaris", + all( + target_arch = "x86", + target_os = "android" + ) ))] let socket = syscall!(accept( listener.as_raw_fd(), @@ -70,7 +80,13 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So // Ensure the socket is closed if either of the `fcntl` calls // error below. let s = unsafe { net::UnixStream::from_raw_fd(socket) }; - syscall!(fcntl(socket, libc::F_SETFD, libc::FD_CLOEXEC)).map(|_| s) + syscall!(fcntl(socket, libc::F_SETFD, libc::FD_CLOEXEC))?; + + // See https://github.com/tokio-rs/mio/issues/1450 + #[cfg(all(target_arch = "x86",target_os = "android"))] + syscall!(fcntl(socket, libc::F_SETFL, libc::O_NONBLOCK))?; + + Ok(s) }); socket |