Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
target_os = "hurd",
target_os = "nto",
target_os = "solaris",
target_os = "vita"
target_os = "vita",
target_os = "cygwin",
)),
))]
use std::os::fd::{AsRawFd, RawFd};
Expand Down Expand Up @@ -449,7 +450,8 @@ impl Poll {
target_os = "hurd",
target_os = "nto",
target_os = "solaris",
target_os = "vita"
target_os = "vita",
target_os = "cygwin",
)),
))]
impl AsRawFd for Poll {
Expand Down Expand Up @@ -750,7 +752,8 @@ impl fmt::Debug for Registry {
target_os = "hurd",
target_os = "nto",
target_os = "solaris",
target_os = "vita"
target_os = "vita",
target_os = "cygwin",
)),
))]
impl AsRawFd for Registry {
Expand All @@ -770,7 +773,8 @@ cfg_os_poll! {
target_os = "hurd",
target_os = "nto",
target_os = "solaris",
target_os = "vita"
target_os = "vita",
target_os = "cygwin",
)),
))]
#[test]
Expand Down
3 changes: 3 additions & 0 deletions src/sys/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ cfg_os_poll! {
target_os = "nto",
target_os = "solaris",
target_os = "vita",
target_os = "cygwin",
), path = "selector/poll.rs")]
mod selector;
pub(crate) use self::selector::*;
Expand Down Expand Up @@ -101,6 +102,7 @@ cfg_os_poll! {
target_os = "redox",
target_os = "solaris",
target_os = "vita",
target_os = "cygwin",
), path = "waker/pipe.rs")]
mod waker;
// NOTE: the `Waker` type is expected in the selector module as the
Expand Down Expand Up @@ -148,6 +150,7 @@ cfg_os_poll! {
target_os = "redox",
target_os = "solaris",
target_os = "vita",
target_os = "cygwin",
),
// Hermit doesn't support pipes.
not(target_os = "hermit"),
Expand Down
1 change: 1 addition & 0 deletions src/sys/unix/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub(crate) fn new_socket(domain: libc::c_int, socket_type: libc::c_int) -> io::R
target_os = "openbsd",
target_os = "solaris",
target_os = "hermit",
target_os = "cygwin",
))]
let socket_type = socket_type | libc::SOCK_NONBLOCK | libc::SOCK_CLOEXEC;
#[cfg(target_os = "nto")]
Expand Down
1 change: 1 addition & 0 deletions src/sys/unix/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub(crate) fn new_raw() -> io::Result<[RawFd; 2]> {
target_os = "redox",
target_os = "solaris",
target_os = "vita",
target_os = "cygwin",
))]
unsafe {
if libc::pipe2(fds.as_mut_ptr(), libc::O_CLOEXEC | libc::O_NONBLOCK) != 0 {
Expand Down
1 change: 1 addition & 0 deletions src/sys/unix/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ pub(crate) fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream,
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
target_os = "cygwin",
))]
let stream = {
syscall!(accept4(
Expand Down
5 changes: 3 additions & 2 deletions tests/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ fn connect_error() {
// Without fastopen we would be getting the connection error
assert!(event.is_writable() || event.is_error());
// Solaris poll(2) says POLLHUP and POLLOUT are mutually exclusive.
#[cfg(not(target_os = "solaris"))]
#[cfg(not(any(target_os = "solaris", target_os = "cygwin")))]
assert!(event.is_write_closed());
break 'outer;
}
Expand Down Expand Up @@ -695,7 +695,8 @@ fn write_shutdown() {
if cfg!(any(
target_os = "hurd",
target_os = "solaris",
target_os = "nto"
target_os = "nto",
target_os = "cygwin",
)) {
wait!(poll, is_readable, false);
} else {
Expand Down
18 changes: 15 additions & 3 deletions tests/tcp_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,10 @@ fn tcp_shutdown_client_read_close_event() {
}

#[test]
#[cfg_attr(windows, ignore = "fails; client write_closed events are not found")]
#[cfg_attr(
any(windows, target_os = "cygwin"),
ignore = "fails; client write_closed events are not found"
)]
#[cfg_attr(
any(
target_os = "android",
Expand Down Expand Up @@ -596,6 +599,7 @@ fn tcp_shutdown_client_write_close_event() {
#[cfg_attr(target_os = "hurd", ignore = "POLLRDHUP isn't supported on GNU/Hurd")]
#[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")]
#[cfg_attr(target_os = "nto", ignore = "POLLRDHUP isn't supported on NTO")]
#[cfg_attr(target_os = "cygwin", ignore = "POLLRDHUP isn't supported on Cygwin")]
fn tcp_shutdown_server_write_close_event() {
let (mut poll, mut events) = init_with_poll();
let barrier = Arc::new(Barrier::new(2));
Expand Down Expand Up @@ -629,6 +633,7 @@ fn tcp_shutdown_server_write_close_event() {
#[cfg_attr(target_os = "hurd", ignore = "POLLRDHUP isn't supported on GNU/Hurd")]
#[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")]
#[cfg_attr(target_os = "nto", ignore = "POLLRDHUP isn't supported on NTO")]
#[cfg_attr(target_os = "cygwin", ignore = "POLLRDHUP isn't supported on Cygwin")]
fn tcp_reset_close_event() {
let (mut poll, mut events) = init_with_poll();

Expand Down Expand Up @@ -673,7 +678,7 @@ fn tcp_reset_close_event() {

#[test]
#[cfg_attr(
windows,
any(windows, target_os = "cygwin"),
ignore = "fails on Windows; client close events are not found"
)]
#[cfg_attr(
Expand Down Expand Up @@ -729,7 +734,14 @@ fn echo_listener(addr: SocketAddr, n_connections: usize) -> (thread::JoinHandle<
// error when the reading side of the peer connection is
// shutdown, we don't consider it an actual here.
.or_else(|err| match err {
ref err if err.kind() == io::ErrorKind::ConnectionReset => Ok(0),
ref err
if matches!(
err.kind(),
io::ErrorKind::ConnectionReset | io::ErrorKind::ConnectionAborted
) =>
{
Ok(0)
}
err => Err(err),
})
.expect("error reading");
Expand Down
12 changes: 9 additions & 3 deletions tests/udp_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,11 @@ fn unconnected_udp_socket_connected_methods() {
);

// Socket is unconnected, but we're using an connected method.
if cfg!(not(any(target_os = "hurd", target_os = "windows"))) {
if cfg!(not(any(
target_os = "hurd",
target_os = "windows",
target_os = "cygwin"
))) {
assert_error(socket1.send(DATA1), "address required");
}
if cfg!(target_os = "windows") {
Expand Down Expand Up @@ -630,15 +634,17 @@ fn connected_udp_socket_unconnected_methods() {
target_os = "android",
target_os = "hurd",
target_os = "linux",
target_os = "windows"
target_os = "windows",
target_os = "cygwin",
)))]
assert_error(socket1.send_to(DATA1, address2), "already connected");
// Even if the address is the same.
#[cfg(not(any(
target_os = "android",
target_os = "hurd",
target_os = "linux",
target_os = "windows"
target_os = "windows",
target_os = "cygwin",
)))]
assert_error(socket1.send_to(DATA1, address3), "already connected");

Expand Down
9 changes: 9 additions & 0 deletions tests/unix_datagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ fn is_send_and_sync() {
target_os = "hurd",
ignore = "getting pathname isn't supported on GNU/Hurd"
)]
#[cfg_attr(
target_os = "cygwin",
ignore = "getting pathname isn't supported on Cygwin"
)]
fn unix_datagram_smoke_unconnected() {
init();
let path1 = temp_file("unix_datagram_smoke_unconnected1");
Expand Down Expand Up @@ -60,6 +64,10 @@ fn unix_datagram_smoke_connected() {
target_os = "hurd",
ignore = "getting pathname isn't supported on GNU/Hurd"
)]
#[cfg_attr(
target_os = "cygwin",
ignore = "getting pathname isn't supported on Cygwin"
)]
fn unix_datagram_smoke_unconnected_from_std() {
init();
let path1 = temp_file("unix_datagram_smoke_unconnected_from_std1");
Expand Down Expand Up @@ -181,6 +189,7 @@ fn unix_datagram_pair() {
#[cfg_attr(target_os = "hurd", ignore = "POLLRDHUP isn't supported on GNU/Hurd")]
#[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")]
#[cfg_attr(target_os = "nto", ignore = "POLLRDHUP isn't supported on NTO")]
#[cfg_attr(target_os = "cygwin", ignore = "POLLRDHUP isn't supported on Cygwin")]
fn unix_datagram_shutdown() {
let (mut poll, mut events) = init_with_poll();
let path1 = temp_file("unix_datagram_shutdown1");
Expand Down
6 changes: 6 additions & 0 deletions tests/unix_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ fn unix_listener_reregister() {
&mut events,
vec![ExpectEvent::new(TOKEN_1, Interest::READABLE)],
);
// Complete handshake to unblock the client thread.
#[cfg(target_os = "cygwin")]
listener.accept().unwrap();

barrier.wait();
handle.join().unwrap();
Expand All @@ -130,6 +133,9 @@ fn unix_listener_deregister() {

poll.registry().deregister(&mut listener).unwrap();
expect_no_events(&mut poll, &mut events);
// Complete handshake to unblock the client thread.
#[cfg(target_os = "cygwin")]
listener.accept().unwrap();

barrier.wait();
handle.join().unwrap();
Expand Down
6 changes: 3 additions & 3 deletions tests/unix_pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn smoke() {

#[test]
#[cfg_attr(
any(target_os = "hurd", target_os = "nto"),
any(target_os = "hurd", target_os = "nto", target_os = "cygwin"),
ignore = "Writer fd close events do not trigger POLLHUP on nto and GNU/Hurd targets"
)]
fn event_when_sender_is_dropped() {
Expand Down Expand Up @@ -96,7 +96,7 @@ fn event_when_sender_is_dropped() {

#[test]
#[cfg_attr(
any(target_os = "hurd", target_os = "nto"),
any(target_os = "hurd", target_os = "nto", target_os = "cygwin"),
ignore = "Writer fd close events do not trigger POLLHUP on nto and GNU/Hurd targets"
)]
fn event_when_receiver_is_dropped() {
Expand Down Expand Up @@ -133,7 +133,7 @@ fn event_when_receiver_is_dropped() {

#[test]
#[cfg_attr(
any(target_os = "hurd", target_os = "nto"),
any(target_os = "hurd", target_os = "nto", target_os = "cygwin"),
ignore = "Writer fd close events do not trigger POLLHUP on nto and GNU/Hurd targets"
)]
fn from_child_process_io() {
Expand Down
50 changes: 48 additions & 2 deletions tests/unix_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,25 @@ fn unix_stream_peer_addr() {
let expected_path = expected_addr.as_pathname().expect("failed to get pathname");

let stream = UnixStream::connect(expected_path).unwrap();
// Complete handshake to unblock the server thread.
#[cfg(target_os = "cygwin")]
let stream = {
let mut stream = stream;
let (mut poll, mut events) = init_with_poll();
poll.registry()
.register(
&mut stream,
TOKEN_1,
Interest::READABLE.add(Interest::WRITABLE),
)
.unwrap();
expect_events(
&mut poll,
&mut events,
vec![ExpectEvent::new(TOKEN_1, Interest::WRITABLE)],
);
stream
};

assert_eq!(
stream.peer_addr().unwrap().as_pathname().unwrap(),
Expand All @@ -205,6 +224,7 @@ fn unix_stream_peer_addr() {
#[cfg_attr(target_os = "hurd", ignore = "POLLRDHUP isn't supported on GNU/Hurd")]
#[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")]
#[cfg_attr(target_os = "nto", ignore = "POLLRDHUP isn't supported on NTO")]
#[cfg_attr(target_os = "cygwin", ignore = "POLLRDHUP isn't supported on Cygwin")]
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");
Expand Down Expand Up @@ -356,7 +376,7 @@ fn unix_stream_shutdown_both() {

stream.shutdown(Shutdown::Both).unwrap();
// Solaris never returns POLLHUP for sockets.
#[cfg(not(target_os = "solaris"))]
#[cfg(not(any(target_os = "solaris", target_os = "cygwin")))]
expect_events(
&mut poll,
&mut events,
Expand Down Expand Up @@ -396,6 +416,7 @@ fn unix_stream_shutdown_both() {
#[cfg_attr(target_os = "hurd", ignore = "POLLRDHUP isn't supported on GNU/Hurd")]
#[cfg_attr(target_os = "solaris", ignore = "POLLRDHUP isn't supported on Solaris")]
#[cfg_attr(target_os = "nto", ignore = "POLLRDHUP isn't supported on NTO")]
#[cfg_attr(target_os = "cygwin", ignore = "POLLRDHUP isn't supported on Cygwin")]
fn unix_stream_shutdown_listener_write() {
let (mut poll, mut events) = init_with_poll();
let barrier = Arc::new(Barrier::new(2));
Expand Down Expand Up @@ -488,6 +509,24 @@ fn unix_stream_deregister() {
let path = remote_addr.as_pathname().expect("failed to get pathname");

let mut stream = UnixStream::connect(path).unwrap();
// Complete handshake to unblock the server thread.
#[cfg(target_os = "cygwin")]
{
let (mut poll, mut events) = init_with_poll();
poll.registry()
.register(
&mut stream,
TOKEN_1,
Interest::READABLE.add(Interest::WRITABLE),
)
.unwrap();
expect_events(
&mut poll,
&mut events,
vec![ExpectEvent::new(TOKEN_1, Interest::WRITABLE)],
);
poll.registry().deregister(&mut stream).unwrap();
}
poll.registry()
.register(&mut stream, TOKEN_1, Interest::WRITABLE)
.unwrap();
Expand Down Expand Up @@ -593,7 +632,14 @@ fn new_echo_listener(
amount
}
Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => continue,
Err(ref err) if err.kind() == io::ErrorKind::ConnectionReset => break,
Err(ref err)
if matches!(
err.kind(),
io::ErrorKind::ConnectionReset | io::ErrorKind::ConnectionAborted
) =>
{
break
}
Err(err) => panic!("{}", err),
};
if n == 0 {
Expand Down
Loading