Skip to content

Commit 65561db

Browse files
authored
Refactor imports and adjust MSG_NOSIGNAL usage
1 parent 04a0d64 commit 65561db

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

Diff for: library/std/src/os/unix/net/stream.rs

+19-18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
#[cfg(any(
2+
target_os = "linux",
3+
target_os = "android",
4+
target_os = "dragonfly",
5+
target_os = "freebsd",
6+
target_os = "openbsd",
7+
target_os = "netbsd",
8+
target_os = "solaris",
9+
target_os = "illumos",
10+
target_os = "haiku",
11+
target_os = "nto",
12+
target_os = "cygwin"
13+
))]
14+
use libc::MSG_NOSIGNAL;
15+
116
use super::{SocketAddr, sockaddr_un};
217
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
318
use super::{SocketAncillary, recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to};
@@ -13,9 +28,7 @@ use super::{SocketAncillary, recv_vectored_with_ancillary_from, send_vectored_wi
1328
target_os = "cygwin"
1429
))]
1530
use super::{UCred, peer_cred};
16-
use crate::cmp;
1731
use crate::ffi::c_void;
18-
use crate::fmt;
1932
use crate::io::{self, IoSlice, IoSliceMut};
2033
use crate::net::Shutdown;
2134
use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
@@ -25,20 +38,8 @@ use crate::sys::cvt;
2538
use crate::sys::net::{Socket, wrlen_t};
2639
use crate::sys_common::{AsInner, FromInner};
2740
use crate::time::Duration;
28-
#[cfg(any(
29-
target_os = "linux",
30-
target_os = "android",
31-
target_os = "dragonfly",
32-
target_os = "freebsd",
33-
target_os = "openbsd",
34-
target_os = "netbsd",
35-
target_os = "solaris",
36-
target_os = "illumos",
37-
target_os = "haiku",
38-
target_os = "nto",
39-
target_os = "cygwin"
40-
))]
41-
use libc::MSG_NOSIGNAL;
41+
use crate::{cmp, fmt};
42+
4243
#[cfg(not(any(
4344
target_os = "linux",
4445
target_os = "android",
@@ -666,8 +667,8 @@ impl<'a> io::Write for &'a UnixStream {
666667
let len = cmp::min(buf.len(), <wrlen_t>::MAX as usize) as wrlen_t;
667668
let ret = cvt(unsafe {
668669
libc::send(self.0.as_raw(), buf.as_ptr() as *const c_void, len, MSG_NOSIGNAL)
669-
})?;
670-
Ok(ret as usize)
670+
})?;
671+
Ok(ret as usize)
671672
}
672673

673674
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {

0 commit comments

Comments
 (0)