@@ -42,6 +42,11 @@ use sys::net::netc::IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP;
4242 target_os = "solaris" , target_os = "haiku" ) ) ) ]
4343use sys:: net:: netc:: IPV6_DROP_MEMBERSHIP ;
4444
45+ #[ cfg( target_os = "linux" ) ]
46+ use libc:: MSG_NOSIGNAL ;
47+ #[ cfg( not( target_os = "linux" ) ) ]
48+ const MSG_NOSIGNAL : c_int = 0x0 ; // unused dummy value
49+
4550////////////////////////////////////////////////////////////////////////////////
4651// sockaddr and misc bindings
4752////////////////////////////////////////////////////////////////////////////////
@@ -225,7 +230,7 @@ impl TcpStream {
225230 c:: send ( * self . inner . as_inner ( ) ,
226231 buf. as_ptr ( ) as * const c_void ,
227232 len,
228- 0 )
233+ MSG_NOSIGNAL )
229234 } ) ?;
230235 Ok ( ret as usize )
231236 }
@@ -449,7 +454,7 @@ impl UdpSocket {
449454 let ret = cvt ( unsafe {
450455 c:: sendto ( * self . inner . as_inner ( ) ,
451456 buf. as_ptr ( ) as * const c_void , len,
452- 0 , dstp, dstlen)
457+ MSG_NOSIGNAL , dstp, dstlen)
453458 } ) ?;
454459 Ok ( ret as usize )
455460 }
@@ -573,7 +578,7 @@ impl UdpSocket {
573578 c:: send ( * self . inner . as_inner ( ) ,
574579 buf. as_ptr ( ) as * const c_void ,
575580 len,
576- 0 )
581+ MSG_NOSIGNAL )
577582 } ) ?;
578583 Ok ( ret as usize )
579584 }
0 commit comments