diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-19 10:29:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-19 10:29:59 +0100 |
| commit | 6d60606a17f09d91cb1bbb8b234a50984550cbb2 (patch) | |
| tree | c3ea77994b6d2a4c66aa5628172db39eb593e401 /src/libstd | |
| parent | 126c8adb33b8ee7f93e9e61c3556413dc41c97d3 (diff) | |
| parent | 58910255aab6634044fe2b6870a0ea6a4bfa0d6a (diff) | |
| download | rust-6d60606a17f09d91cb1bbb8b234a50984550cbb2.tar.gz rust-6d60606a17f09d91cb1bbb8b234a50984550cbb2.zip | |
Rollup merge of #67389 - reitermarkus:dummy-variable, r=shepmaster
Remove `SO_NOSIGPIPE` dummy variable on platforms that don't use it.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/sys/unix/net.rs | 17 | ||||
| -rw-r--r-- | src/libstd/sys/vxworks/net.rs | 1 |
2 files changed, 6 insertions, 12 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) } } diff --git a/src/libstd/sys/vxworks/net.rs b/src/libstd/sys/vxworks/net.rs index 85f5fcff2c2..54466ff2c2e 100644 --- a/src/libstd/sys/vxworks/net.rs +++ b/src/libstd/sys/vxworks/net.rs @@ -19,7 +19,6 @@ pub extern crate libc as netc; pub type wrlen_t = size_t; const SOCK_CLOEXEC: c_int = 0; -const SO_NOSIGPIPE: c_int = 0; pub struct Socket(FileDesc); |
