Skip to content

Commit 5891025

Browse files
committed
Remove SO_NOSIGPIPE dummy variable on platforms that don't use it.
1 parent 3ed3b8b commit 5891025

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

src/libstd/sys/unix/net.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@ use libc::SOCK_CLOEXEC;
2828
#[cfg(not(target_os = "linux"))]
2929
const SOCK_CLOEXEC: c_int = 0;
3030

31-
// Another conditional constant for name resolution: Macos et iOS use
32-
// SO_NOSIGPIPE as a setsockopt flag to disable SIGPIPE emission on socket.
33-
// Other platforms do otherwise.
34-
#[cfg(target_vendor = "apple")]
35-
use libc::SO_NOSIGPIPE;
36-
#[cfg(not(target_vendor = "apple"))]
37-
const SO_NOSIGPIPE: c_int = 0;
38-
3931
pub struct Socket(FileDesc);
4032

4133
pub fn init() {}
@@ -89,9 +81,12 @@ impl Socket {
8981
let fd = FileDesc::new(fd);
9082
fd.set_cloexec()?;
9183
let socket = Socket(fd);
92-
if cfg!(target_vendor = "apple") {
93-
setsockopt(&socket, libc::SOL_SOCKET, SO_NOSIGPIPE, 1)?;
94-
}
84+
85+
// macOS and iOS use `SO_NOSIGPIPE` as a `setsockopt`
86+
// flag to disable `SIGPIPE` emission on socket.
87+
#[cfg(target_vendor = "apple")]
88+
setsockopt(&socket, libc::SOL_SOCKET, libc::SO_NOSIGPIPE, 1)?;
89+
9590
Ok(socket)
9691
}
9792
}

src/libstd/sys/vxworks/net.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub extern crate libc as netc;
1919
pub type wrlen_t = size_t;
2020

2121
const SOCK_CLOEXEC: c_int = 0;
22-
const SO_NOSIGPIPE: c_int = 0;
2322

2423
pub struct Socket(FileDesc);
2524

0 commit comments

Comments
 (0)