From 19354e46d20c179c78223450421101ad7ef6317f Mon Sep 17 00:00:00 2001 From: Berrysoft Date: Mon, 7 Apr 2025 11:12:10 +0800 Subject: [PATCH 1/5] Add cygwin support --- src/socket.rs | 6 ++++++ src/sys/unix.rs | 9 +++++++-- tests/socket.rs | 26 +++++++++++++++++++++----- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/socket.rs b/src/socket.rs index 7f2a1edf..600a9b90 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -1254,6 +1254,7 @@ impl Socket { target_os = "nto", target_os = "espidf", target_os = "vita", + target_os = "cygwin", )))] pub fn join_multicast_v4_n( &self, @@ -1287,6 +1288,7 @@ impl Socket { target_os = "nto", target_os = "espidf", target_os = "vita", + target_os = "cygwin", )))] pub fn leave_multicast_v4_n( &self, @@ -1577,6 +1579,7 @@ impl Socket { target_os = "nto", target_os = "espidf", target_os = "vita", + target_os = "cygwin", )))] pub fn set_recv_tos_v4(&self, recv_tos: bool) -> io::Result<()> { unsafe { @@ -1608,6 +1611,7 @@ impl Socket { target_os = "nto", target_os = "espidf", target_os = "vita", + target_os = "cygwin", )))] pub fn recv_tos_v4(&self) -> io::Result { unsafe { @@ -1978,6 +1982,7 @@ impl Socket { target_os = "hurd", target_os = "espidf", target_os = "vita", + target_os = "cygwin", )) ))] pub fn recv_hoplimit_v6(&self) -> io::Result { @@ -2006,6 +2011,7 @@ impl Socket { target_os = "hurd", target_os = "espidf", target_os = "vita", + target_os = "cygwin", )) ))] pub fn set_recv_hoplimit_v6(&self, recv_hoplimit: bool) -> io::Result<()> { diff --git a/src/sys/unix.rs b/src/sys/unix.rs index 8e24f4e5..5adafd41 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -140,6 +140,7 @@ pub(crate) use libc::IPV6_HDRINCL; target_os = "haiku", target_os = "espidf", target_os = "vita", + target_os = "cygwin", )) ))] pub(crate) use libc::IPV6_RECVHOPLIMIT; @@ -173,6 +174,7 @@ pub(crate) use libc::IP_HDRINCL; target_os = "nto", target_os = "espidf", target_os = "vita", + target_os = "cygwin", )))] pub(crate) use libc::IP_RECVTOS; #[cfg(not(any( @@ -383,6 +385,7 @@ type IovLen = usize; target_os = "watchos", target_os = "espidf", target_os = "vita", + target_os = "cygwin", ))] type IovLen = c_int; @@ -1200,6 +1203,7 @@ pub(crate) fn set_tcp_keepalive(fd: Socket, keepalive: &TcpKeepalive) -> io::Res target_os = "netbsd", target_os = "tvos", target_os = "watchos", + target_os = "cygwin", ))] { if let Some(interval) = keepalive.interval { @@ -1333,6 +1337,7 @@ pub(crate) fn from_in6_addr(addr: in6_addr) -> Ipv6Addr { target_os = "nto", target_os = "espidf", target_os = "vita", + target_os = "cygwin", )))] pub(crate) const fn to_mreqn( multiaddr: &Ipv4Addr, @@ -1956,7 +1961,7 @@ impl crate::Socket { /// [`set_reuse_port`]: crate::Socket::set_reuse_port #[cfg(all( feature = "all", - not(any(target_os = "solaris", target_os = "illumos")) + not(any(target_os = "solaris", target_os = "illumos", target_os = "cygwin")) ))] pub fn reuse_port(&self) -> io::Result { unsafe { @@ -1972,7 +1977,7 @@ impl crate::Socket { /// there's a socket already listening on this port. #[cfg(all( feature = "all", - not(any(target_os = "solaris", target_os = "illumos")) + not(any(target_os = "solaris", target_os = "illumos", target_os = "cygwin")) ))] pub fn set_reuse_port(&self, reuse: bool) -> io::Result<()> { unsafe { diff --git a/tests/socket.rs b/tests/socket.rs index a2dca668..d9dd90b4 100644 --- a/tests/socket.rs +++ b/tests/socket.rs @@ -1247,6 +1247,7 @@ fn r#type() { target_os = "tvos", target_os = "watchos", target_os = "vita", + target_os = "cygwin", )), feature = "all", ))] @@ -1356,12 +1357,21 @@ test!(out_of_band_inline, set_out_of_band_inline(true)); test!(reuse_address, set_reuse_address(true)); #[cfg(all( feature = "all", - not(any(windows, target_os = "solaris", target_os = "illumos")) + not(any( + windows, + target_os = "solaris", + target_os = "illumos", + target_os = "cygwin", + )) ))] test!(reuse_port, set_reuse_port(true)); #[cfg(all(feature = "all", target_os = "freebsd"))] test!(reuse_port_lb, set_reuse_port_lb(true)); -#[cfg(all(feature = "all", unix, not(target_os = "redox")))] +#[cfg(all( + feature = "all", + unix, + not(any(target_os = "redox", target_os = "cygwin")), +))] test!( #[cfg_attr(target_os = "linux", ignore = "Different value returned")] mss, @@ -1413,6 +1423,7 @@ test!(IPv4 ttl_v4, set_ttl_v4(40)); target_os = "solaris", target_os = "illumos", target_os = "haiku", + target_os = "cygwin", )))] test!(IPv4 tos_v4, set_tos_v4(96)); @@ -1428,10 +1439,11 @@ test!(IPv4 tos_v4, set_tos_v4(96)); target_os = "windows", target_os = "vita", target_os = "haiku", + target_os = "cygwin", )))] test!(IPv4 recv_tos_v4, set_recv_tos_v4(true)); -#[cfg(not(windows))] // TODO: returns `WSAENOPROTOOPT` (10042) on Windows. +#[cfg(not(any(windows, target_os = "cygwin")))] // TODO: returns `WSAENOPROTOOPT` (10042) on Windows. test!(IPv4 broadcast, set_broadcast(true)); #[cfg(not(target_os = "vita"))] @@ -1442,11 +1454,12 @@ test!(IPv6 unicast_hops_v6, set_unicast_hops_v6(20)); target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", - target_os = "vita" + target_os = "vita", + target_os = "cygwin", )))] test!(IPv6 only_v6, set_only_v6(true)); // IPv6 socket are already IPv6 only on FreeBSD and Windows. -#[cfg(any(windows, target_os = "freebsd"))] +#[cfg(any(windows, target_os = "freebsd", target_os = "cygwin"))] test!(IPv6 only_v6, set_only_v6(false)); #[cfg(all( @@ -1476,6 +1489,7 @@ test!(IPv6 tclass_v6, set_tclass_v6(96)); target_os = "windows", target_os = "vita", target_os = "haiku", + target_os = "cygwin", )))] test!(IPv6 recv_tclass_v6, set_recv_tclass_v6(true)); @@ -1493,6 +1507,7 @@ test!(IPv6 recv_tclass_v6, set_recv_tclass_v6(true)); target_os = "windows", target_os = "vita", target_os = "haiku", + target_os = "cygwin", )) ))] test!(IPv6 recv_hoplimit_v6, set_recv_hoplimit_v6(true)); @@ -1520,6 +1535,7 @@ test!(IPv6 multicast_all_v6, set_multicast_all_v6(false)); target_os = "redox", target_os = "solaris", target_os = "vita", + target_os = "cygwin", )))] fn join_leave_multicast_v4_n() { let socket = Socket::new(Domain::IPV4, Type::DGRAM, None).unwrap(); From 8e3572205ee6a153bde78005fa2781a0e413c72a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E9=80=B8?= Date: Mon, 7 Apr 2025 20:33:00 +0800 Subject: [PATCH 2/5] Fix unix test on cygwin --- tests/socket.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/socket.rs b/tests/socket.rs index d9dd90b4..bd26be02 100644 --- a/tests/socket.rs +++ b/tests/socket.rs @@ -554,6 +554,24 @@ fn unix_sockets_supported() -> bool { true } +// An extension on cygwin. It disables initial handshake on AF_UNIX sockets. +// https://cygwin.com/git/?p=newlib-cygwin.git;a=commit;h=697b9afe0 +#[cfg(target_os = "cygwin")] +fn set_no_peercred(s: &Socket) { + let res = unsafe { + libc::setsockopt( + s.as_raw_fd(), + libc::SOL_SOCKET, + libc::SO_PEERCRED, + std::ptr::null(), + 0, + ) + }; + if res == -1 { + panic!("{:?}", std::io::Error::last_os_error()); + } +} + #[test] fn unix() { if !unix_sockets_supported() { @@ -568,10 +586,14 @@ fn unix() { let addr = SockAddr::unix(path).unwrap(); let listener = Socket::new(Domain::UNIX, Type::STREAM, None).unwrap(); + #[cfg(target_os = "cygwin")] + set_no_peercred(&listener); listener.bind(&addr).unwrap(); listener.listen(10).unwrap(); let mut a = Socket::new(Domain::UNIX, Type::STREAM, None).unwrap(); + #[cfg(target_os = "cygwin")] + set_no_peercred(&a); a.connect(&addr).unwrap(); let mut b = listener.accept().unwrap().0; From 71537b6070830afc4e74aff5b535f0985431f333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E9=80=B8?= Date: Mon, 7 Apr 2025 20:35:11 +0800 Subject: [PATCH 3/5] Try adding cygwin target to check --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 20ca0d1c..f3b7fce3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -83,6 +83,7 @@ jobs: - sparcv9-sun-solaris - x86_64-apple-darwin - x86_64-apple-ios + - x86_64-pc-cygwin - x86_64-pc-solaris # Fails with: # `rror calling dlltool 'x86_64-w64-mingw32-dlltool': No such file or From e379cf76ec656c47165311665e287288cedd7d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E9=80=B8?= Date: Mon, 7 Apr 2025 21:16:08 +0800 Subject: [PATCH 4/5] Fix flags and docs --- src/lib.rs | 2 ++ src/socket.rs | 10 ++++++-- src/sys/unix.rs | 64 +++++++++++++++++++++++++++++++++++++++---------- tests/socket.rs | 5 +++- 4 files changed, 65 insertions(+), 16 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4d39b05d..6f8a4a4b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -516,6 +516,7 @@ impl TcpKeepalive { target_os = "tvos", target_os = "watchos", target_os = "windows", + target_os = "cygwin", ))] pub const fn with_interval(self, interval: Duration) -> Self { Self { @@ -543,6 +544,7 @@ impl TcpKeepalive { target_os = "netbsd", target_os = "tvos", target_os = "watchos", + target_os = "cygwin", ) ))] pub const fn with_retries(self, retries: u32) -> Self { diff --git a/src/socket.rs b/src/socket.rs index 600a9b90..b44d8a5c 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -271,6 +271,7 @@ impl Socket { target_os = "linux", target_os = "netbsd", target_os = "openbsd", + target_os = "cygwin", ))] return self._accept4(libc::SOCK_CLOEXEC); @@ -284,6 +285,7 @@ impl Socket { target_os = "linux", target_os = "netbsd", target_os = "openbsd", + target_os = "cygwin", )))] { let (socket, addr) = self.accept_raw()?; @@ -752,6 +754,7 @@ const fn set_common_type(ty: Type) -> Type { target_os = "linux", target_os = "netbsd", target_os = "openbsd", + target_os = "cygwin", ))] let ty = ty._cloexec(); @@ -781,6 +784,7 @@ fn set_common_flags(socket: Socket) -> io::Result { target_os = "openbsd", target_os = "espidf", target_os = "vita", + target_os = "cygwin", )) ))] socket._set_cloexec(true)?; @@ -956,7 +960,7 @@ impl Socket { /// For more information about this option, see [`set_passcred`]. /// /// [`set_passcred`]: Socket::set_passcred - #[cfg(all(unix, target_os = "linux"))] + #[cfg(all(unix, any(target_os = "linux", target_os = "cygwin")))] pub fn passcred(&self) -> io::Result { unsafe { getsockopt::(self.as_raw(), sys::SOL_SOCKET, sys::SO_PASSCRED) @@ -968,7 +972,7 @@ impl Socket { /// /// If this option is enabled, enables the receiving of the `SCM_CREDENTIALS` /// control messages. - #[cfg(all(unix, target_os = "linux"))] + #[cfg(all(unix, any(target_os = "linux", target_os = "cygwin")))] pub fn set_passcred(&self, passcred: bool) -> io::Result<()> { unsafe { setsockopt( @@ -2069,6 +2073,7 @@ impl Socket { target_os = "netbsd", target_os = "tvos", target_os = "watchos", + target_os = "cygwin", ) ))] pub fn keepalive_interval(&self) -> io::Result { @@ -2098,6 +2103,7 @@ impl Socket { target_os = "netbsd", target_os = "tvos", target_os = "watchos", + target_os = "cygwin", ) ))] pub fn keepalive_retries(&self) -> io::Result { diff --git a/src/sys/unix.rs b/src/sys/unix.rs index 5adafd41..f4187e56 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -72,6 +72,7 @@ use std::{io, slice}; target_os = "macos", target_os = "tvos", target_os = "watchos", + target_os = "cygwin", )))] use libc::ssize_t; use libc::{in6_addr, in_addr}; @@ -201,7 +202,7 @@ pub(crate) use libc::SO_LINGER; target_os = "watchos", ))] pub(crate) use libc::SO_LINGER_SEC as SO_LINGER; -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "cygwin"))] pub(crate) use libc::SO_PASSCRED; pub(crate) use libc::{ ip_mreq as IpMreq, linger, IPPROTO_IP, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, @@ -273,6 +274,7 @@ pub(crate) use libc::{ target_os = "netbsd", target_os = "tvos", target_os = "watchos", + target_os = "cygwin", ) ))] pub(crate) use libc::{TCP_KEEPCNT, TCP_KEEPINTVL}; @@ -322,6 +324,7 @@ macro_rules! syscall { target_os = "macos", target_os = "tvos", target_os = "watchos", + target_os = "cygwin", )))] const MAX_BUF_LEN: usize = ssize_t::MAX as usize; @@ -339,6 +342,7 @@ const MAX_BUF_LEN: usize = ssize_t::MAX as usize; target_os = "macos", target_os = "tvos", target_os = "watchos", + target_os = "cygwin", ))] const MAX_BUF_LEN: usize = c_int::MAX as usize - 1; @@ -428,7 +432,8 @@ impl Type { target_os = "illumos", target_os = "linux", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", + target_os = "cygwin", ) ))] pub const fn nonblocking(self) -> Type { @@ -450,6 +455,7 @@ impl Type { target_os = "openbsd", target_os = "redox", target_os = "solaris", + target_os = "cygwin", ) ))] pub const fn cloexec(self) -> Type { @@ -468,6 +474,7 @@ impl Type { target_os = "openbsd", target_os = "redox", target_os = "solaris", + target_os = "cygwin", ))] pub(crate) const fn _cloexec(self) -> Type { Type(self.0 | libc::SOCK_CLOEXEC) @@ -581,7 +588,10 @@ impl RecvFlags { /// on the local host. /// /// On Unix this corresponds to the `MSG_DONTROUTE` flag. - #[cfg(all(feature = "all", any(target_os = "android", target_os = "linux")))] + #[cfg(all( + feature = "all", + any(target_os = "android", target_os = "linux", target_os = "cygwin"), + ))] pub const fn is_dontroute(self) -> bool { self.0 & libc::MSG_DONTROUTE != 0 } @@ -598,7 +608,10 @@ impl std::fmt::Debug for RecvFlags { s.field("is_truncated", &self.is_truncated()); #[cfg(all(feature = "all", any(target_os = "android", target_os = "linux")))] s.field("is_confirm", &self.is_confirm()); - #[cfg(all(feature = "all", any(target_os = "android", target_os = "linux")))] + #[cfg(all( + feature = "all", + any(target_os = "android", target_os = "linux", target_os = "cygwin"), + ))] s.field("is_dontroute", &self.is_dontroute()); s.finish() } @@ -770,7 +783,7 @@ impl SockAddr { // Abstract addresses only exist on Linux. // NOTE: although Fuchsia does define `AF_UNIX` it's not actually implemented. // See https://github.com/rust-lang/socket2/pull/403#discussion_r1123557978 - || (cfg!(not(any(target_os = "linux", target_os = "android"))) + || (cfg!(not(any(target_os = "linux", target_os = "android", target_os = "cygwin"))) && storage.sun_path[0] == 0) }) .unwrap_or_default() @@ -843,14 +856,14 @@ impl SockAddr { pub fn as_abstract_namespace(&self) -> Option<&[u8]> { // NOTE: although Fuchsia does define `AF_UNIX` it's not actually implemented. // See https://github.com/rust-lang/socket2/pull/403#discussion_r1123557978 - #[cfg(any(target_os = "linux", target_os = "android"))] + #[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin"))] { self.as_sockaddr_un().and_then(|storage| { (self.len() > offset_of_path(storage) as _ && storage.sun_path[0] == 0) .then(|| self.path_bytes(storage, true)) }) } - #[cfg(not(any(target_os = "linux", target_os = "android")))] + #[cfg(not(any(target_os = "linux", target_os = "android", target_os = "cygwin")))] None } } @@ -1419,6 +1432,7 @@ impl crate::Socket { target_os = "linux", target_os = "netbsd", target_os = "openbsd", + target_os = "cygwin", ) ))] pub fn accept4(&self, flags: c_int) -> io::Result<(crate::Socket, SockAddr)> { @@ -1434,6 +1448,7 @@ impl crate::Socket { target_os = "linux", target_os = "netbsd", target_os = "openbsd", + target_os = "cygwin", ))] pub(crate) fn _accept4(&self, flags: c_int) -> io::Result<(crate::Socket, SockAddr)> { // Safety: `accept4` initialises the `SockAddr` for us. @@ -1556,6 +1571,7 @@ impl crate::Socket { target_os = "freebsd", target_os = "fuchsia", target_os = "linux", + target_os = "cygwin", ) ))] pub fn is_listener(&self) -> io::Result { @@ -1685,7 +1701,12 @@ impl crate::Socket { /// [`set_quickack`]: crate::Socket::set_quickack #[cfg(all( feature = "all", - any(target_os = "android", target_os = "fuchsia", target_os = "linux") + any( + target_os = "android", + target_os = "fuchsia", + target_os = "linux", + target_os = "cygwin", + ) ))] pub fn quickack(&self) -> io::Result { unsafe { @@ -1702,7 +1723,12 @@ impl crate::Socket { /// internal protocol processing and factors such as delayed ack timeouts occurring and data transfer. #[cfg(all( feature = "all", - any(target_os = "android", target_os = "fuchsia", target_os = "linux") + any( + target_os = "android", + target_os = "fuchsia", + target_os = "linux", + target_os = "cygwin", + ) ))] pub fn set_quickack(&self, quickack: bool) -> io::Result<()> { unsafe { @@ -2277,7 +2303,12 @@ impl crate::Socket { /// approximately 49.71 days. #[cfg(all( feature = "all", - any(target_os = "android", target_os = "fuchsia", target_os = "linux") + any( + target_os = "android", + target_os = "fuchsia", + target_os = "linux", + target_os = "cygwin", + ) ))] pub fn set_tcp_user_timeout(&self, timeout: Option) -> io::Result<()> { let timeout = timeout.map_or(0, |to| { @@ -2300,7 +2331,12 @@ impl crate::Socket { /// [`set_tcp_user_timeout`]: crate::Socket::set_tcp_user_timeout #[cfg(all( feature = "all", - any(target_os = "android", target_os = "fuchsia", target_os = "linux") + any( + target_os = "android", + target_os = "fuchsia", + target_os = "linux", + target_os = "cygwin", + ) ))] pub fn tcp_user_timeout(&self) -> io::Result> { unsafe { @@ -2374,7 +2410,8 @@ impl crate::Socket { target_os = "linux", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", + target_os = "cygwin", ) ))] pub fn tclass_v6(&self) -> io::Result { @@ -2398,7 +2435,8 @@ impl crate::Socket { target_os = "linux", target_os = "macos", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", + target_os = "cygwin", ) ))] pub fn set_tclass_v6(&self, tclass: u32) -> io::Result<()> { diff --git a/tests/socket.rs b/tests/socket.rs index bd26be02..5017cfe1 100644 --- a/tests/socket.rs +++ b/tests/socket.rs @@ -186,7 +186,10 @@ fn socket_address_unix_unnamed() { } #[test] -#[cfg(all(any(target_os = "linux", target_os = "android"), feature = "all"))] +#[cfg(all( + any(target_os = "linux", target_os = "android", target_os = "cygwin"), + feature = "all", +))] fn socket_address_unix_abstract_namespace() { let path = "\0h".repeat(108 / 2); let addr = SockAddr::unix(&path).unwrap(); From 0d1639c32dd1eaefcff6d0ab4bb8f694ffd9121e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E9=80=B8?= Date: Mon, 14 Apr 2025 22:07:17 +0800 Subject: [PATCH 5/5] Add `set_no_peercred` for cygwin --- src/sys/unix.rs | 16 ++++++++++++++++ tests/socket.rs | 22 ++-------------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/sys/unix.rs b/src/sys/unix.rs index f4187e56..ab64d273 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -282,6 +282,8 @@ pub(crate) use libc::{TCP_KEEPCNT, TCP_KEEPINTVL}; // See this type in the Windows file. pub(crate) type Bool = c_int; +#[cfg(target_os = "cygwin")] +use libc::SO_PEERCRED; #[cfg(any( target_os = "ios", target_os = "visionos", @@ -1499,6 +1501,20 @@ impl crate::Socket { } } + /// Sets `SO_PEERCRED` to null on the socket. + /// It disables the initial handshake of unix domain sockets. + #[cfg(target_os = "cygwin")] + pub fn set_no_peercred(&self) -> io::Result<()> { + syscall!(setsockopt( + self.as_raw(), + SOL_SOCKET, + SO_PEERCRED, + ptr::null_mut(), + 0, + )) + .map(|_| ()) + } + /// Sets `SO_NOSIGPIPE` on the socket. #[cfg(all( feature = "all", diff --git a/tests/socket.rs b/tests/socket.rs index 5017cfe1..77e30d35 100644 --- a/tests/socket.rs +++ b/tests/socket.rs @@ -557,24 +557,6 @@ fn unix_sockets_supported() -> bool { true } -// An extension on cygwin. It disables initial handshake on AF_UNIX sockets. -// https://cygwin.com/git/?p=newlib-cygwin.git;a=commit;h=697b9afe0 -#[cfg(target_os = "cygwin")] -fn set_no_peercred(s: &Socket) { - let res = unsafe { - libc::setsockopt( - s.as_raw_fd(), - libc::SOL_SOCKET, - libc::SO_PEERCRED, - std::ptr::null(), - 0, - ) - }; - if res == -1 { - panic!("{:?}", std::io::Error::last_os_error()); - } -} - #[test] fn unix() { if !unix_sockets_supported() { @@ -590,13 +572,13 @@ fn unix() { let listener = Socket::new(Domain::UNIX, Type::STREAM, None).unwrap(); #[cfg(target_os = "cygwin")] - set_no_peercred(&listener); + listener.set_no_peercred().unwrap(); listener.bind(&addr).unwrap(); listener.listen(10).unwrap(); let mut a = Socket::new(Domain::UNIX, Type::STREAM, None).unwrap(); #[cfg(target_os = "cygwin")] - set_no_peercred(&a); + a.set_no_peercred().unwrap(); a.connect(&addr).unwrap(); let mut b = listener.accept().unwrap().0;