diff options
| author | Maarten de Vries <maarten@de-vri.es> | 2020-10-31 14:20:18 +0100 |
|---|---|---|
| committer | Maarten de Vries <maarten@de-vri.es> | 2020-11-06 14:17:48 +0100 |
| commit | 3bee37c290fdd362fd4fd393606cc53acf1e7375 (patch) | |
| tree | fc8cff5a24a029b70d5bae41e2bf2d6019ccb90d /library/std/src/sys/unix/net.rs | |
| parent | 59c6ae615e5547610c3348b466a45ff2a5b3d935 (diff) | |
| download | rust-3bee37c290fdd362fd4fd393606cc53acf1e7375.tar.gz rust-3bee37c290fdd362fd4fd393606cc53acf1e7375.zip | |
Disable accept4 on Android.
Diffstat (limited to 'library/std/src/sys/unix/net.rs')
| -rw-r--r-- | library/std/src/sys/unix/net.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/library/std/src/sys/unix/net.rs b/library/std/src/sys/unix/net.rs index 71c6aa5a0e7..378d690f8bf 100644 --- a/library/std/src/sys/unix/net.rs +++ b/library/std/src/sys/unix/net.rs @@ -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", @@ -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); |
