Skip to content

Commit

Permalink
Remove SO_NOSIGPIPE dummy variable on platforms that don't use it.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Dec 18, 2019
1 parent 3ed3b8b commit 5891025
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
17 changes: 6 additions & 11 deletions src/libstd/sys/unix/net.rs
Expand Up @@ -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() {}
Expand Down Expand Up @@ -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)
}
}
Expand Down
1 change: 0 additions & 1 deletion src/libstd/sys/vxworks/net.rs
Expand Up @@ -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);

Expand Down

0 comments on commit 5891025

Please sign in to comment.