File tree Expand file tree Collapse file tree 2 files changed +6
-12
lines changed Expand file tree Collapse file tree 2 files changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -28,14 +28,6 @@ use libc::SOCK_CLOEXEC;
2828#[ cfg( not( target_os = "linux" ) ) ]
2929const 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-
3931pub struct Socket ( FileDesc ) ;
4032
4133pub 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 }
Original file line number Diff line number Diff line change @@ -19,7 +19,6 @@ pub extern crate libc as netc;
1919pub type wrlen_t = size_t ;
2020
2121const SOCK_CLOEXEC : c_int = 0 ;
22- const SO_NOSIGPIPE : c_int = 0 ;
2322
2423pub struct Socket ( FileDesc ) ;
2524
You can’t perform that action at this time.
0 commit comments