diff options
| author | Mathieu Poumeyrol <mathieu.poumeyrol@snips.ai> | 2016-09-28 14:06:34 +0200 |
|---|---|---|
| committer | Mathieu Poumeyrol <mathieu.poumeyrol@snips.ai> | 2016-09-28 19:44:20 +0200 |
| commit | 5980d5bfddb8f1e92cee7f9a156c4758615bee4b (patch) | |
| tree | 022065e6a10d078382de69cb35812ea742b15c61 /src/libstd | |
| parent | ed5e5428192f6f72afcb4becc3d78a18133613df (diff) | |
| download | rust-5980d5bfddb8f1e92cee7f9a156c4758615bee4b.tar.gz rust-5980d5bfddb8f1e92cee7f9a156c4758615bee4b.zip | |
use MSG_NOSIGNAL from liblibc
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/sys/common/net.rs | 11 | ||||
| -rw-r--r-- | src/libstd/sys/unix/ext/net.rs | 5 |
2 files changed, 6 insertions, 10 deletions
diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs index d0d387c6ed9..2599bb660e8 100644 --- a/src/libstd/sys/common/net.rs +++ b/src/libstd/sys/common/net.rs @@ -43,7 +43,7 @@ use sys::net::netc::IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP; use sys::net::netc::IPV6_DROP_MEMBERSHIP; #[cfg(target_os = "linux")] -const MSG_NOSIGNAL: c_int = 0x4000; +use libc::MSG_NOSIGNAL; #[cfg(not(target_os = "linux"))] const MSG_NOSIGNAL: c_int = 0x0; // unused dummy value @@ -226,12 +226,11 @@ impl TcpStream { pub fn write(&self, buf: &[u8]) -> io::Result<usize> { let len = cmp::min(buf.len(), <wrlen_t>::max_value() as usize) as wrlen_t; - let flags = if cfg!(target_os = "linux") { MSG_NOSIGNAL } else { 0 }; let ret = cvt(unsafe { c::send(*self.inner.as_inner(), buf.as_ptr() as *const c_void, len, - flags) + MSG_NOSIGNAL) })?; Ok(ret as usize) } @@ -452,11 +451,10 @@ impl UdpSocket { pub fn send_to(&self, buf: &[u8], dst: &SocketAddr) -> io::Result<usize> { let len = cmp::min(buf.len(), <wrlen_t>::max_value() as usize) as wrlen_t; let (dstp, dstlen) = dst.into_inner(); - let flags = if cfg!(target_os = "linux") { MSG_NOSIGNAL } else { 0 }; let ret = cvt(unsafe { c::sendto(*self.inner.as_inner(), buf.as_ptr() as *const c_void, len, - flags, dstp, dstlen) + MSG_NOSIGNAL, dstp, dstlen) })?; Ok(ret as usize) } @@ -576,12 +574,11 @@ impl UdpSocket { pub fn send(&self, buf: &[u8]) -> io::Result<usize> { let len = cmp::min(buf.len(), <wrlen_t>::max_value() as usize) as wrlen_t; - let flags = if cfg!(target_os = "linux") { MSG_NOSIGNAL } else { 0 }; let ret = cvt(unsafe { c::send(*self.inner.as_inner(), buf.as_ptr() as *const c_void, len, - flags) + MSG_NOSIGNAL) })?; Ok(ret as usize) } diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index f2e40714b46..03ff8d9787f 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -29,7 +29,7 @@ use sys::net::Socket; use sys_common::{AsInner, FromInner, IntoInner}; #[cfg(target_os = "linux")] -const MSG_NOSIGNAL: libc::c_int = 0x4000; +use libc::MSG_NOSIGNAL; #[cfg(not(target_os = "linux"))] const MSG_NOSIGNAL: libc::c_int = 0x0; // unused dummy value @@ -691,12 +691,11 @@ impl UnixDatagram { fn inner(d: &UnixDatagram, buf: &[u8], path: &Path) -> io::Result<usize> { unsafe { let (addr, len) = sockaddr_un(path)?; - let flags = if cfg!(target_os = "linux") { MSG_NOSIGNAL } else { 0 }; let count = cvt(libc::sendto(*d.0.as_inner(), buf.as_ptr() as *const _, buf.len(), - flags, + MSG_NOSIGNAL, &addr as *const _ as *const _, len))?; Ok(count as usize) |
