diff options
| author | Markus Reiter <me@reitermark.us> | 2019-12-18 08:46:00 +0100 | 
|---|---|---|
| committer | Markus Reiter <me@reitermark.us> | 2019-12-18 08:46:00 +0100 | 
| commit | 58910255aab6634044fe2b6870a0ea6a4bfa0d6a (patch) | |
| tree | 2f53042bf46214d7326fe243c11abf9aba449940 /src/libstd/sys/unix/net.rs | |
| parent | 3ed3b8bb7b100afecf7d5f52eafbb70fec27f537 (diff) | |
| download | rust-58910255aab6634044fe2b6870a0ea6a4bfa0d6a.tar.gz rust-58910255aab6634044fe2b6870a0ea6a4bfa0d6a.zip | |
Remove `SO_NOSIGPIPE` dummy variable on platforms that don't use it.
Diffstat (limited to 'src/libstd/sys/unix/net.rs')
| -rw-r--r-- | src/libstd/sys/unix/net.rs | 17 | 
1 files changed, 6 insertions, 11 deletions
| diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs index 946b2b9d8de..5d101ed1f2e 100644 --- a/src/libstd/sys/unix/net.rs +++ b/src/libstd/sys/unix/net.rs @@ -28,14 +28,6 @@ use libc::SOCK_CLOEXEC; #[cfg(not(target_os = "linux"))] const SOCK_CLOEXEC: c_int = 0; -// Another conditional constant for name resolution: Macos et iOS use -// SO_NOSIGPIPE as a setsockopt flag to disable SIGPIPE emission on socket. -// Other platforms do otherwise. -#[cfg(target_vendor = "apple")] -use libc::SO_NOSIGPIPE; -#[cfg(not(target_vendor = "apple"))] -const SO_NOSIGPIPE: c_int = 0; - pub struct Socket(FileDesc); pub fn init() {} @@ -89,9 +81,12 @@ impl Socket { let fd = FileDesc::new(fd); fd.set_cloexec()?; let socket = Socket(fd); - if cfg!(target_vendor = "apple") { - setsockopt(&socket, libc::SOL_SOCKET, SO_NOSIGPIPE, 1)?; - } + + // macOS and iOS use `SO_NOSIGPIPE` as a `setsockopt` + // flag to disable `SIGPIPE` emission on socket. + #[cfg(target_vendor = "apple")] + setsockopt(&socket, libc::SOL_SOCKET, libc::SO_NOSIGPIPE, 1)?; + Ok(socket) } } | 
