Skip to content

Commit

Permalink
Remove epoll_create1 missing work around
Browse files Browse the repository at this point in the history
This was introduces in Linux Linux 2.6.27, glibc 2.9 and Android API
level 21.

Since both are equal or lower than our supported versions we don't need
this fallback any longer.
  • Loading branch information
Thomasdezeeuw committed Dec 14, 2023
1 parent de0ef90 commit 7074b47
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions src/sys/unix/selector/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,10 @@ pub struct Selector {

impl Selector {
pub fn new() -> io::Result<Selector> {
let ep = match syscall!(epoll_create1(libc::EPOLL_CLOEXEC)) {
Ok(ep) => ep as RawFd,
Err(err) => {
// When `epoll_create1` is not available fall back to use
// `epoll_create` followed by `fcntl`.
if let Some(libc::ENOSYS) = err.raw_os_error() {
match syscall!(epoll_create(1024)) {
Ok(ep) => match syscall!(fcntl(ep, libc::F_SETFD, libc::FD_CLOEXEC)) {
Ok(ep) => ep as RawFd,
Err(err) => {
// `fcntl` failed, cleanup `ep`.
let _ = unsafe { libc::close(ep) };
return Err(err);
}
},
Err(err) => return Err(err),
}
} else {
return Err(err);
}
}
};

Ok(Selector {
#[cfg(debug_assertions)]
id: NEXT_ID.fetch_add(1, Ordering::Relaxed),
ep,
ep: syscall!(epoll_create1(libc::EPOLL_CLOEXEC))?,
})
}

Expand Down

0 comments on commit 7074b47

Please sign in to comment.