diff --git a/src/sys/unix/net.rs b/src/sys/unix/net.rs index ed58adaad..5a473bd2d 100644 --- a/src/sys/unix/net.rs +++ b/src/sys/unix/net.rs @@ -25,6 +25,8 @@ pub(crate) fn new_socket(domain: libc::c_int, socket_type: libc::c_int) -> io::R target_os = "hermit", ))] let socket_type = socket_type | libc::SOCK_NONBLOCK | libc::SOCK_CLOEXEC; + #[cfg(target_os = "nto")] + let socket_type = socket_type | libc::SOCK_CLOEXEC; let socket = syscall!(socket(domain, socket_type, 0))?; @@ -54,13 +56,14 @@ pub(crate) fn new_socket(domain: libc::c_int, socket_type: libc::c_int) -> io::R target_os = "watchos", target_os = "espidf", target_os = "vita", + target_os = "nto", ))] { if let Err(err) = syscall!(fcntl(socket, libc::F_SETFL, libc::O_NONBLOCK)) { let _ = syscall!(close(socket)); return Err(err); } - #[cfg(not(any(target_os = "espidf", target_os = "vita")))] + #[cfg(not(any(target_os = "espidf", target_os = "vita", target_os = "nto")))] if let Err(err) = syscall!(fcntl(socket, libc::F_SETFD, libc::FD_CLOEXEC)) { let _ = syscall!(close(socket)); return Err(err); @@ -117,6 +120,7 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_ target_os = "espidf", target_os = "vita", target_os = "hermit", + target_os = "nto", ))] sin_len: 0, #[cfg(target_os = "vita")] @@ -148,6 +152,7 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_ target_os = "watchos", target_os = "espidf", target_os = "vita", + target_os = "nto", ))] sin6_len: 0, #[cfg(target_os = "vita")] diff --git a/src/sys/unix/pipe.rs b/src/sys/unix/pipe.rs index 7f23787f7..c44106a29 100644 --- a/src/sys/unix/pipe.rs +++ b/src/sys/unix/pipe.rs @@ -33,6 +33,7 @@ pub(crate) fn new_raw() -> io::Result<[RawFd; 2]> { target_os = "tvos", target_os = "watchos", target_os = "espidf", + target_os = "nto", ))] unsafe { // For platforms that don't have `pipe2(2)` we need to manually set the @@ -71,6 +72,7 @@ pub(crate) fn new_raw() -> io::Result<[RawFd; 2]> { target_os = "espidf", target_os = "solaris", target_os = "vita", + target_os = "nto", )))] compile_error!("unsupported target for `mio::unix::pipe`"); diff --git a/src/sys/unix/tcp.rs b/src/sys/unix/tcp.rs index 0c379b5f8..a8d8d0b46 100644 --- a/src/sys/unix/tcp.rs +++ b/src/sys/unix/tcp.rs @@ -95,6 +95,7 @@ pub(crate) fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream, target_os = "espidf", target_os = "vita", target_os = "hermit", + target_os = "nto", all(target_arch = "x86", target_os = "android"), ))] let stream = { @@ -114,6 +115,7 @@ pub(crate) fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream, target_os = "espidf", target_os = "vita", target_os = "hermit", + target_os = "nto", ))] syscall!(fcntl(s.as_raw_fd(), libc::F_SETFL, libc::O_NONBLOCK))?; diff --git a/src/sys/unix/uds/listener.rs b/src/sys/unix/uds/listener.rs index 65d332c83..b94243720 100644 --- a/src/sys/unix/uds/listener.rs +++ b/src/sys/unix/uds/listener.rs @@ -53,6 +53,7 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So target_os = "watchos", target_os = "espidf", target_os = "vita", + target_os = "nto", // Android x86's seccomp profile forbids calls to `accept4(2)` // See https://github.com/tokio-rs/mio/issues/1445 for details all(target_arch = "x86", target_os = "android"), @@ -78,6 +79,7 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So target_os = "watchos", target_os = "espidf", target_os = "vita", + target_os = "nto", all(target_arch = "x86", target_os = "android") ))] let socket = syscall!(accept( @@ -97,6 +99,7 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So all(target_arch = "x86", target_os = "android"), target_os = "espidf", target_os = "vita", + target_os = "nto", ))] syscall!(fcntl(socket, libc::F_SETFL, libc::O_NONBLOCK))?; diff --git a/src/sys/unix/uds/mod.rs b/src/sys/unix/uds/mod.rs index 376ee05ee..20367fd09 100644 --- a/src/sys/unix/uds/mod.rs +++ b/src/sys/unix/uds/mod.rs @@ -82,8 +82,11 @@ cfg_os_poll! { target_os = "watchos", target_os = "espidf", target_os = "vita", + target_os = "nto", )))] let flags = flags | libc::SOCK_NONBLOCK | libc::SOCK_CLOEXEC; + #[cfg(target_os = "nto")] + let flags = flags | libc::SOCK_CLOEXEC; let mut fds = [-1; 2]; syscall!(socketpair(libc::AF_UNIX, flags, 0, fds.as_mut_ptr()))?; @@ -103,13 +106,14 @@ cfg_os_poll! { target_os = "watchos", target_os = "espidf", target_os = "vita", + target_os = "nto", ))] { syscall!(fcntl(fds[0], libc::F_SETFL, libc::O_NONBLOCK))?; - #[cfg(not(any(target_os = "espidf", target_os = "vita")))] + #[cfg(not(any(target_os = "espidf", target_os = "vita", target_os = "nto")))] syscall!(fcntl(fds[0], libc::F_SETFD, libc::FD_CLOEXEC))?; syscall!(fcntl(fds[1], libc::F_SETFL, libc::O_NONBLOCK))?; - #[cfg(not(any(target_os = "espidf", target_os = "vita")))] + #[cfg(not(any(target_os = "espidf", target_os = "vita", target_os = "nto")))] syscall!(fcntl(fds[1], libc::F_SETFD, libc::FD_CLOEXEC))?; } diff --git a/tests/tcp.rs b/tests/tcp.rs index 4eb42e178..49e731936 100644 --- a/tests/tcp.rs +++ b/tests/tcp.rs @@ -701,8 +701,8 @@ fn write_shutdown() { // Now, shutdown the write half of the socket. socket.shutdown(Shutdown::Write).unwrap(); - // POLLRDHUP isn't supported on Solaris - if cfg!(target_os = "solaris") { + // POLLRDHUP isn't supported on Solaris, + if cfg!(any(target_os = "solaris", target_os = "nto")) { wait!(poll, is_readable, false); } else { wait!(poll, is_readable, true); diff --git a/tests/tcp_stream.rs b/tests/tcp_stream.rs index ad2224c24..b307a2ad6 100644 --- a/tests/tcp_stream.rs +++ b/tests/tcp_stream.rs @@ -515,6 +515,7 @@ fn no_events_after_deregister() { ignore = "fails on Windows; client read closed events are not triggered" )] #[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")] +#[cfg_attr(target_os = "nto", ignore = "POLLRDHUP isn't supported on NTO")] fn tcp_shutdown_client_read_close_event() { let (mut poll, mut events) = init_with_poll(); let barrier = Arc::new(Barrier::new(2)); @@ -552,7 +553,8 @@ fn tcp_shutdown_client_read_close_event() { target_os = "android", target_os = "illumos", target_os = "solaris", - target_os = "linux" + target_os = "linux", + target_os = "nto" ), ignore = "fails; client write_closed events are not found" )] @@ -588,6 +590,7 @@ fn tcp_shutdown_client_write_close_event() { #[test] #[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")] +#[cfg_attr(target_os = "nto", ignore = "POLLRDHUP isn't supported on NTO")] fn tcp_shutdown_server_write_close_event() { let (mut poll, mut events) = init_with_poll(); let barrier = Arc::new(Barrier::new(2)); @@ -619,6 +622,7 @@ fn tcp_shutdown_server_write_close_event() { #[test] #[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")] +#[cfg_attr(target_os = "nto", ignore = "POLLRDHUP isn't supported on NTO")] fn tcp_reset_close_event() { let (mut poll, mut events) = init_with_poll(); diff --git a/tests/unix_datagram.rs b/tests/unix_datagram.rs index 31784051c..2345989b7 100644 --- a/tests/unix_datagram.rs +++ b/tests/unix_datagram.rs @@ -167,6 +167,7 @@ fn unix_datagram_pair() { #[test] #[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")] +#[cfg_attr(target_os = "nto", ignore = "POLLRDHUP isn't supported on NTO")] fn unix_datagram_shutdown() { let (mut poll, mut events) = init_with_poll(); let path1 = temp_file("unix_datagram_shutdown1"); diff --git a/tests/unix_pipe.rs b/tests/unix_pipe.rs index f8e6464c9..dc79026c4 100644 --- a/tests/unix_pipe.rs +++ b/tests/unix_pipe.rs @@ -53,6 +53,10 @@ fn smoke() { } #[test] +#[cfg_attr( + target_os = "nto", + ignore = "Writer fd close events do not trigger POLLHUP on nto target" +)] fn event_when_sender_is_dropped() { let mut poll = Poll::new().unwrap(); let mut events = Events::with_capacity(8); @@ -91,6 +95,10 @@ fn event_when_sender_is_dropped() { } #[test] +#[cfg_attr( + target_os = "nto", + ignore = "Read fd close events do not trigger POLLHUP on nto target" +)] fn event_when_receiver_is_dropped() { let mut poll = Poll::new().unwrap(); let mut events = Events::with_capacity(8); @@ -124,10 +132,13 @@ fn event_when_receiver_is_dropped() { } #[test] +#[cfg_attr( + target_os = "nto", + ignore = "Read/Write close eventsdo not trigger POLLHUP on nto target" +)] fn from_child_process_io() { // `cat` simply echo everything that we write via standard in. let mut child = Command::new("cat") - .env_clear() .stdin(Stdio::piped()) .stdout(Stdio::piped()) .spawn() @@ -175,7 +186,6 @@ fn from_child_process_io() { fn nonblocking_child_process_io() { // `cat` simply echo everything that we write via standard in. let mut child = Command::new("cat") - .env_clear() .stdin(Stdio::piped()) .stdout(Stdio::piped()) .spawn() diff --git a/tests/unix_stream.rs b/tests/unix_stream.rs index ecafa5440..9098b7d17 100644 --- a/tests/unix_stream.rs +++ b/tests/unix_stream.rs @@ -187,6 +187,7 @@ fn unix_stream_peer_addr() { #[test] #[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")] +#[cfg_attr(target_os = "nto", ignore = "POLLRDHUP isn't supported on NTO")] 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"); @@ -365,6 +366,7 @@ fn unix_stream_shutdown_both() { #[test] #[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")] +#[cfg_attr(target_os = "nto", ignore = "POLLRDHUP isn't supported on NTO")] fn unix_stream_shutdown_listener_write() { let (mut poll, mut events) = init_with_poll(); let barrier = Arc::new(Barrier::new(2));