Skip to content

Commit

Permalink
Use libc::accept4 on Android instead of raw syscall.
Browse files Browse the repository at this point in the history
  • Loading branch information
de-vri-es committed Feb 24, 2021
1 parent 6b56603 commit 3ac62ca
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions library/std/src/sys/unix/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ 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 @@ -206,13 +207,6 @@ 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 3ac62ca

Please sign in to comment.