Skip to content

Commit

Permalink
Disable accept4 on Android.
Browse files Browse the repository at this point in the history
  • Loading branch information
de-vri-es committed Nov 6, 2020
1 parent 59c6ae6 commit 3bee37c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion library/std/src/sys/unix/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ impl Socket {
// glibc 2.10 and musl 0.9.5.
cfg_if::cfg_if! {
if #[cfg(any(
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "illumos",
Expand All @@ -207,6 +206,13 @@ impl Socket {
libc::accept4(self.0.raw(), storage, len, libc::SOCK_CLOEXEC)
})?;
Ok(Socket(FileDesc::new(fd)))
// While the Android kernel supports the syscall,
// it is not included in all versions of Android's libc.
} else if #[cfg(target_os = "android")] {
let fd = cvt_r(|| unsafe {
libc::syscall(libc::SYS_accept4, self.0.raw(), storage, len, libc::SOCK_CLOEXEC)
})?;
Ok(Socket(FileDesc::new(fd as c_int)))
} else {
let fd = cvt_r(|| unsafe { libc::accept(self.0.raw(), storage, len) })?;
let fd = FileDesc::new(fd);
Expand Down

0 comments on commit 3bee37c

Please sign in to comment.