Skip to content

Commit 926917b

Browse files
committed
Move Socket::set_no_peercred to src/sys/unix.rs
It's Cygwin (Unix) only.
1 parent 5d7bd84 commit 926917b

File tree

2 files changed

+16
-29
lines changed

2 files changed

+16
-29
lines changed

src/socket.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -992,30 +992,6 @@ impl Socket {
992992
}
993993
}
994994

995-
/// Sets `SO_PEERCRED` to null on the socket.
996-
///
997-
/// This is a Cygwin extension.
998-
///
999-
/// Normally the Unix domain sockets of Cygwin are implemented by TCP sockets,
1000-
/// so it performs a handshake on `connect` and `accept` to verify the remote
1001-
/// connection and exchange peer cred info. At the time of writing, this
1002-
/// means that `connect` on a Unix domain socket will block until the server
1003-
/// calls `accept` on Cygwin. This behavior is inconsistent with most other
1004-
/// platforms, and this option can be used to disable that.
1005-
///
1006-
/// See also: the [mailing list](https://inbox.sourceware.org/cygwin/TYCPR01MB10926FF8926CA63704867ADC8F8AA2@TYCPR01MB10926.jpnprd01.prod.outlook.com/)
1007-
#[cfg(any(doc, target_os = "cygwin"))]
1008-
pub fn set_no_peercred(&self) -> io::Result<()> {
1009-
#[cfg(target_os = "cygwin")]
1010-
{
1011-
self._set_no_peercred()
1012-
}
1013-
#[cfg(not(target_os = "cygwin"))]
1014-
{
1015-
unimplemented!()
1016-
}
1017-
}
1018-
1019995
/// Get value for the `SO_RCVBUF` option on this socket.
1020996
///
1021997
/// For more information about this option, see [`set_recv_buffer_size`].

src/sys/unix.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,6 @@ pub(crate) use libc::{TCP_KEEPCNT, TCP_KEEPINTVL};
282282
// See this type in the Windows file.
283283
pub(crate) type Bool = c_int;
284284

285-
#[cfg(target_os = "cygwin")]
286-
use libc::SO_PEERCRED;
287285
#[cfg(any(
288286
target_os = "ios",
289287
target_os = "visionos",
@@ -1501,12 +1499,25 @@ impl crate::Socket {
15011499
}
15021500
}
15031501

1502+
/// Sets `SO_PEERCRED` to null on the socket.
1503+
///
1504+
/// This is a Cygwin extension.
1505+
///
1506+
/// Normally the Unix domain sockets of Cygwin are implemented by TCP sockets,
1507+
/// so it performs a handshake on `connect` and `accept` to verify the remote
1508+
/// connection and exchange peer cred info. At the time of writing, this
1509+
/// means that `connect` on a Unix domain socket will block until the server
1510+
/// calls `accept` on Cygwin. This behavior is inconsistent with most other
1511+
/// platforms, and this option can be used to disable that.
1512+
///
1513+
/// See also: the [mailing list](https://inbox.sourceware.org/cygwin/TYCPR01MB10926FF8926CA63704867ADC8F8AA2@TYCPR01MB10926.jpnprd01.prod.outlook.com/)
15041514
#[cfg(target_os = "cygwin")]
1505-
pub(crate) fn _set_no_peercred(&self) -> io::Result<()> {
1515+
#[cfg(any(doc, target_os = "cygwin"))]
1516+
pub fn set_no_peercred(&self) -> io::Result<()> {
15061517
syscall!(setsockopt(
15071518
self.as_raw(),
1508-
SOL_SOCKET,
1509-
SO_PEERCRED,
1519+
libc::SOL_SOCKET,
1520+
libc::SO_PEERCRED,
15101521
ptr::null_mut(),
15111522
0,
15121523
))

0 commit comments

Comments
 (0)