Skip to content

Commit 3bee37c

Browse files
committed
Disable accept4 on Android.
1 parent 59c6ae6 commit 3bee37c

File tree

1 file changed

+7
-1
lines changed
  • library/std/src/sys/unix

1 file changed

+7
-1
lines changed

library/std/src/sys/unix/net.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ impl Socket {
195195
// glibc 2.10 and musl 0.9.5.
196196
cfg_if::cfg_if! {
197197
if #[cfg(any(
198-
target_os = "android",
199198
target_os = "dragonfly",
200199
target_os = "freebsd",
201200
target_os = "illumos",
@@ -207,6 +206,13 @@ impl Socket {
207206
libc::accept4(self.0.raw(), storage, len, libc::SOCK_CLOEXEC)
208207
})?;
209208
Ok(Socket(FileDesc::new(fd)))
209+
// While the Android kernel supports the syscall,
210+
// it is not included in all versions of Android's libc.
211+
} else if #[cfg(target_os = "android")] {
212+
let fd = cvt_r(|| unsafe {
213+
libc::syscall(libc::SYS_accept4, self.0.raw(), storage, len, libc::SOCK_CLOEXEC)
214+
})?;
215+
Ok(Socket(FileDesc::new(fd as c_int)))
210216
} else {
211217
let fd = cvt_r(|| unsafe { libc::accept(self.0.raw(), storage, len) })?;
212218
let fd = FileDesc::new(fd);

0 commit comments

Comments
 (0)