]> git.lizzy.rs Git - rust.git/commitdiff
Remove `SO_NOSIGPIPE` dummy variable on platforms that don't use it.
authorMarkus Reiter <me@reitermark.us>
Wed, 18 Dec 2019 07:46:00 +0000 (08:46 +0100)
committerMarkus Reiter <me@reitermark.us>
Wed, 18 Dec 2019 07:46:00 +0000 (08:46 +0100)
src/libstd/sys/unix/net.rs
src/libstd/sys/vxworks/net.rs

index 946b2b9d8decfa1ccc04c57738b7c5756242112e..5d101ed1f2e2bc84efee1bd110319d59408be2c0 100644 (file)
 #[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 @@ pub fn new_raw(fam: c_int, ty: c_int) -> io::Result<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)
         }
     }
index 85f5fcff2c259e3dd9c60d58e4761f53dc453b25..54466ff2c2e07851ae3c2bc4e0cb4940d649cd06 100644 (file)
@@ -19,7 +19,6 @@
 pub type wrlen_t = size_t;
 
 const SOCK_CLOEXEC: c_int = 0;
-const SO_NOSIGPIPE: c_int = 0;
 
 pub struct Socket(FileDesc);