diff --git a/src/poll.rs b/src/poll.rs index d904eb97c..f487db262 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -1,4 +1,4 @@ -#[cfg(all(unix, not(mio_unsupported_force_poll_poll)))] +#[cfg(all(unix, not(any(target_os = "solaris", mio_unsupported_force_poll_poll))))] use std::os::unix::io::{AsRawFd, RawFd}; #[cfg(all(debug_assertions, not(target_os = "wasi")))] use std::sync::atomic::{AtomicBool, Ordering}; @@ -423,7 +423,7 @@ impl Poll { } } -#[cfg(all(unix, not(mio_unsupported_force_poll_poll)))] +#[cfg(all(unix, not(any(target_os = "solaris", mio_unsupported_force_poll_poll))))] impl AsRawFd for Poll { fn as_raw_fd(&self) -> RawFd { self.registry.as_raw_fd() @@ -710,7 +710,7 @@ impl fmt::Debug for Registry { } } -#[cfg(all(unix, not(mio_unsupported_force_poll_poll)))] +#[cfg(all(unix, not(any(target_os = "solaris", mio_unsupported_force_poll_poll))))] impl AsRawFd for Registry { fn as_raw_fd(&self) -> RawFd { self.selector.as_raw_fd() @@ -720,7 +720,7 @@ impl AsRawFd for Registry { cfg_os_poll! { #[cfg(all( unix, - not(mio_unsupported_force_poll_poll) + not(any(target_os = "solaris", mio_unsupported_force_poll_poll)) ))] #[test] pub fn as_raw_fd() { diff --git a/src/sys/unix/mod.rs b/src/sys/unix/mod.rs index eb268b9f4..ac6018877 100644 --- a/src/sys/unix/mod.rs +++ b/src/sys/unix/mod.rs @@ -34,7 +34,7 @@ cfg_os_poll! { cfg_io_source! { // Both `kqueue` and `epoll` don't need to hold any user space state. - #[cfg(not(mio_unsupported_force_poll_poll))] + #[cfg(not(any(target_os = "solaris", mio_unsupported_force_poll_poll)))] mod stateless_io_source { use std::io; use std::os::unix::io::RawFd; @@ -87,10 +87,10 @@ cfg_os_poll! { } } - #[cfg(not(mio_unsupported_force_poll_poll))] + #[cfg(not(any(target_os = "solaris", mio_unsupported_force_poll_poll)))] pub(crate) use self::stateless_io_source::IoSourceState; - #[cfg(mio_unsupported_force_poll_poll)] + #[cfg(any(target_os = "solaris", mio_unsupported_force_poll_poll))] pub(crate) use self::selector::IoSourceState; } @@ -105,6 +105,7 @@ cfg_os_poll! { target_os = "netbsd", target_os = "openbsd", target_os = "redox", + target_os = "solaris", ))] pub(crate) mod pipe; } diff --git a/src/sys/unix/net.rs b/src/sys/unix/net.rs index 81b53a388..5e0318065 100644 --- a/src/sys/unix/net.rs +++ b/src/sys/unix/net.rs @@ -21,6 +21,7 @@ pub(crate) fn new_socket(domain: libc::c_int, socket_type: libc::c_int) -> io::R target_os = "linux", target_os = "netbsd", target_os = "openbsd", + target_os = "solaris", ))] let socket_type = socket_type | libc::SOCK_NONBLOCK | libc::SOCK_CLOEXEC; @@ -139,7 +140,7 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_ target_os = "espidf", ))] sin6_len: 0, - #[cfg(target_os = "illumos")] + #[cfg(any(target_os = "illumos", target_os = "solaris"))] __sin6_src_id: 0, }; diff --git a/src/sys/unix/pipe.rs b/src/sys/unix/pipe.rs index 8e92dd37d..c03ec74ef 100644 --- a/src/sys/unix/pipe.rs +++ b/src/sys/unix/pipe.rs @@ -17,6 +17,7 @@ pub(crate) fn new_raw() -> io::Result<[RawFd; 2]> { target_os = "openbsd", target_os = "illumos", target_os = "redox", + target_os = "solaris", ))] unsafe { if libc::pipe2(fds.as_mut_ptr(), libc::O_CLOEXEC | libc::O_NONBLOCK) != 0 { @@ -64,6 +65,7 @@ pub(crate) fn new_raw() -> io::Result<[RawFd; 2]> { target_os = "netbsd", target_os = "openbsd", target_os = "redox", + target_os = "solaris", target_os = "tvos", target_os = "watchos", target_os = "espidf", @@ -556,7 +558,7 @@ impl IntoRawFd for Receiver { } } -#[cfg(not(target_os = "illumos"))] +#[cfg(not(any(target_os = "illumos", target_os = "solaris")))] fn set_nonblocking(fd: RawFd, nonblocking: bool) -> io::Result<()> { let value = nonblocking as libc::c_int; if unsafe { libc::ioctl(fd, libc::FIONBIO, &value) } == -1 { @@ -566,7 +568,7 @@ fn set_nonblocking(fd: RawFd, nonblocking: bool) -> io::Result<()> { } } -#[cfg(target_os = "illumos")] +#[cfg(any(target_os = "illumos", target_os = "solaris"))] fn set_nonblocking(fd: RawFd, nonblocking: bool) -> io::Result<()> { let flags = unsafe { libc::fcntl(fd, libc::F_GETFL) }; if flags < 0 { diff --git a/src/sys/unix/selector/mod.rs b/src/sys/unix/selector/mod.rs index 7fa73b8d6..a232c80bd 100644 --- a/src/sys/unix/selector/mod.rs +++ b/src/sys/unix/selector/mod.rs @@ -20,10 +20,10 @@ mod epoll; ))] pub(crate) use self::epoll::{event, Event, Events, Selector}; -#[cfg(mio_unsupported_force_poll_poll)] +#[cfg(any(target_os = "solaris", mio_unsupported_force_poll_poll))] mod poll; -#[cfg(mio_unsupported_force_poll_poll)] +#[cfg(any(target_os = "solaris", mio_unsupported_force_poll_poll))] pub(crate) use self::poll::{event, Event, Events, IoSourceState, Selector}; #[cfg(all( diff --git a/src/sys/unix/tcp.rs b/src/sys/unix/tcp.rs index c0bc40ad1..b25290d1c 100644 --- a/src/sys/unix/tcp.rs +++ b/src/sys/unix/tcp.rs @@ -67,6 +67,7 @@ pub(crate) fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream, target_os = "linux", target_os = "netbsd", target_os = "openbsd", + target_os = "solaris", ))] let stream = { syscall!(accept4( diff --git a/src/sys/unix/waker.rs b/src/sys/unix/waker.rs index 4b73df32d..8cd5817f7 100644 --- a/src/sys/unix/waker.rs +++ b/src/sys/unix/waker.rs @@ -1,5 +1,5 @@ #[cfg(all( - not(mio_unsupported_force_poll_poll), + not(any(target_os = "solaris", mio_unsupported_force_poll_poll)), not(all( not(mio_unsupported_force_waker_pipe), any( @@ -51,7 +51,7 @@ mod fdbased { } #[cfg(all( - not(mio_unsupported_force_poll_poll), + not(any(target_os = "solaris", mio_unsupported_force_poll_poll)), not(all( not(mio_unsupported_force_waker_pipe), any( @@ -205,6 +205,7 @@ pub use self::kqueue::Waker; target_os = "netbsd", target_os = "openbsd", target_os = "redox", + target_os = "solaris", ))] mod pipe { use crate::sys::unix::pipe; @@ -250,7 +251,7 @@ mod pipe { } } - #[cfg(mio_unsupported_force_poll_poll)] + #[cfg(any(target_os = "solaris", mio_unsupported_force_poll_poll))] pub fn ack_and_reset(&self) { self.empty(); } @@ -276,7 +277,7 @@ mod pipe { } #[cfg(all( - mio_unsupported_force_poll_poll, + any(target_os = "solaris", mio_unsupported_force_poll_poll), any( mio_unsupported_force_waker_pipe, target_os = "aix", @@ -285,11 +286,12 @@ mod pipe { target_os = "netbsd", target_os = "openbsd", target_os = "redox", + target_os = "solaris", ) ))] pub(crate) use self::pipe::WakerInternal; -#[cfg(mio_unsupported_force_poll_poll)] +#[cfg(any(target_os = "solaris", mio_unsupported_force_poll_poll))] mod poll { use crate::sys::Selector; use crate::Token; @@ -315,5 +317,5 @@ mod poll { } } -#[cfg(mio_unsupported_force_poll_poll)] +#[cfg(any(target_os = "solaris", mio_unsupported_force_poll_poll))] pub use self::poll::Waker; diff --git a/tests/tcp.rs b/tests/tcp.rs index 82ed6bcbf..2c61403d5 100644 --- a/tests/tcp.rs +++ b/tests/tcp.rs @@ -572,6 +572,8 @@ fn connect_error() { for event in &events { if event.token() == Token(0) { assert!(event.is_writable()); + // Solaris poll(2) says POLLHUP and POLLOUT are mutually exclusive. + #[cfg(not(target_os = "solaris"))] assert!(event.is_write_closed()); break 'outer; } @@ -698,7 +700,12 @@ fn write_shutdown() { // Now, shutdown the write half of the socket. socket.shutdown(Shutdown::Write).unwrap(); - wait!(poll, is_readable, true); + // POLLRDHUP isn't supported on Solaris + if cfg!(target_os = "solaris") { + wait!(poll, is_readable, false); + } else { + wait!(poll, is_readable, true); + } } struct MyHandler { diff --git a/tests/tcp_stream.rs b/tests/tcp_stream.rs index df9b3f2e3..4dfe0f5f2 100644 --- a/tests/tcp_stream.rs +++ b/tests/tcp_stream.rs @@ -514,6 +514,7 @@ fn no_events_after_deregister() { windows, ignore = "fails on Windows; client read closed events are not triggered" )] +#[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")] fn tcp_shutdown_client_read_close_event() { let (mut poll, mut events) = init_with_poll(); let barrier = Arc::new(Barrier::new(2)); @@ -547,7 +548,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 = "android", target_os = "illumos", target_os = "linux"), + 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() { @@ -581,6 +587,7 @@ fn tcp_shutdown_client_write_close_event() { } #[test] +#[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")] fn tcp_shutdown_server_write_close_event() { let (mut poll, mut events) = init_with_poll(); let barrier = Arc::new(Barrier::new(2)); @@ -611,6 +618,7 @@ fn tcp_shutdown_server_write_close_event() { } #[test] +#[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")] fn tcp_reset_close_event() { let (mut poll, mut events) = init_with_poll(); @@ -659,7 +667,7 @@ fn tcp_reset_close_event() { ignore = "fails on Windows; client close events are not found" )] #[cfg_attr( - any(target_os = "illumos"), + any(target_os = "illumos", target_os = "solaris"), ignore = "fails; client write_closed events are not found" )] fn tcp_shutdown_client_both_close_event() { diff --git a/tests/unix_datagram.rs b/tests/unix_datagram.rs index 1b05f5150..31784051c 100644 --- a/tests/unix_datagram.rs +++ b/tests/unix_datagram.rs @@ -166,6 +166,7 @@ fn unix_datagram_pair() { } #[test] +#[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")] fn unix_datagram_shutdown() { let (mut poll, mut events) = init_with_poll(); let path1 = temp_file("unix_datagram_shutdown1"); diff --git a/tests/unix_stream.rs b/tests/unix_stream.rs index 9bb9d52fd..ecafa5440 100644 --- a/tests/unix_stream.rs +++ b/tests/unix_stream.rs @@ -186,6 +186,7 @@ fn unix_stream_peer_addr() { } #[test] +#[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")] fn unix_stream_shutdown_read() { let (mut poll, mut events) = init_with_poll(); let (handle, remote_addr) = new_echo_listener(1, "unix_stream_shutdown_read"); @@ -326,6 +327,8 @@ fn unix_stream_shutdown_both() { ); stream.shutdown(Shutdown::Both).unwrap(); + // Solaris never returns POLLHUP for sockets. + #[cfg(not(target_os = "solaris"))] expect_events( &mut poll, &mut events, @@ -361,6 +364,7 @@ fn unix_stream_shutdown_both() { } #[test] +#[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")] fn unix_stream_shutdown_listener_write() { let (mut poll, mut events) = init_with_poll(); let barrier = Arc::new(Barrier::new(2));