diff --git a/src/poll.rs b/src/poll.rs index e4cd804af..64462819f 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -174,6 +174,7 @@ use std::{fmt, io}; /// | NetBSD | [kqueue] | /// | OpenBSD | [kqueue] | /// | Solaris | [epoll] | +/// | illumos | [epoll] | /// | Windows | [IOCP] | /// | iOS | [kqueue] | /// | macOS | [kqueue] | diff --git a/src/sys/unix/net.rs b/src/sys/unix/net.rs index fdbeb14a1..5193b91cc 100644 --- a/src/sys/unix/net.rs +++ b/src/sys/unix/net.rs @@ -27,6 +27,7 @@ pub(crate) fn new_socket( target_os = "android", target_os = "dragonfly", target_os = "freebsd", + target_os = "illumos", target_os = "linux", target_os = "netbsd", target_os = "openbsd" diff --git a/src/sys/unix/selector/epoll.rs b/src/sys/unix/selector/epoll.rs index b869aa9cc..4728717e5 100644 --- a/src/sys/unix/selector/epoll.rs +++ b/src/sys/unix/selector/epoll.rs @@ -21,10 +21,15 @@ pub struct Selector { impl Selector { pub fn new() -> io::Result { - // According to libuv `EPOLL_CLOEXEC` is not defined on Android API < - // 21. But `EPOLL_CLOEXEC` is an alias for `O_CLOEXEC` on all platforms, - // so we use that instead. - syscall!(epoll_create1(libc::O_CLOEXEC)).map(|ep| Selector { + // According to libuv, `EPOLL_CLOEXEC` is not defined on Android API < + // 21. But `EPOLL_CLOEXEC` is an alias for `O_CLOEXEC` on that platform, + // so we use it instead. + #[cfg(target_os = "android")] + let flag = libc::O_CLOEXEC; + #[cfg(not(target_os = "android"))] + let flag = libc::EPOLL_CLOEXEC; + + syscall!(epoll_create1(flag)).map(|ep| Selector { #[cfg(debug_assertions)] id: NEXT_ID.fetch_add(1, Ordering::Relaxed), ep, @@ -212,6 +217,7 @@ pub mod event { } } +#[cfg(target_os = "android")] #[test] fn assert_close_on_exec_flag() { // This assertion need to be true for Selector::new. diff --git a/src/sys/unix/selector/mod.rs b/src/sys/unix/selector/mod.rs index 82475c897..752589817 100644 --- a/src/sys/unix/selector/mod.rs +++ b/src/sys/unix/selector/mod.rs @@ -1,7 +1,17 @@ -#[cfg(any(target_os = "linux", target_os = "android", target_os = "solaris"))] +#[cfg(any( + target_os = "android", + target_os = "illumos", + target_os = "linux", + target_os = "solaris" +))] mod epoll; -#[cfg(any(target_os = "linux", target_os = "android", target_os = "solaris"))] +#[cfg(any( + target_os = "android", + target_os = "illumos", + target_os = "linux", + target_os = "solaris" +))] pub(crate) use self::epoll::{event, Event, Events, Selector}; #[cfg(any( diff --git a/src/sys/unix/tcp.rs b/src/sys/unix/tcp.rs index d07e6bc62..08a28c0ed 100644 --- a/src/sys/unix/tcp.rs +++ b/src/sys/unix/tcp.rs @@ -61,6 +61,7 @@ pub fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream, Socket target_os = "android", target_os = "dragonfly", target_os = "freebsd", + target_os = "illumos", target_os = "linux", target_os = "netbsd", target_os = "openbsd" diff --git a/src/sys/unix/waker.rs b/src/sys/unix/waker.rs index 16707cd19..1305bd689 100644 --- a/src/sys/unix/waker.rs +++ b/src/sys/unix/waker.rs @@ -100,6 +100,7 @@ pub use self::kqueue::Waker; #[cfg(any( target_os = "dragonfly", + target_os = "illumos", target_os = "netbsd", target_os = "openbsd", target_os = "solaris" @@ -165,6 +166,7 @@ mod pipe { #[cfg(any( target_os = "dragonfly", + target_os = "illumos", target_os = "netbsd", target_os = "openbsd", target_os = "solaris" diff --git a/tests/tcp_stream.rs b/tests/tcp_stream.rs index 11d8d841d..096b72366 100644 --- a/tests/tcp_stream.rs +++ b/tests/tcp_stream.rs @@ -540,7 +540,12 @@ fn tcp_shutdown_client_read_close_event() { #[test] #[cfg_attr(windows, ignore = "fails; client write_closed events are not found")] #[cfg_attr( - any(target_os = "linux", target_os = "android", target_os = "solaris"), + any( + target_os = "android", + target_os = "illumos", + target_os = "linux", + target_os = "solaris" + ), ignore = "fails; client write_closed events are not found" )] fn tcp_shutdown_client_write_close_event() {