Skip to content

Commit 15cd5a1

Browse files
committed
std: Fix usage of SOCK_CLOEXEC
This code path was intended to only get executed on Linux, but unfortunately the `cfg!` was malformed so it actually never got executed.
1 parent 8052f73 commit 15cd5a1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libstd/sys/unix/net.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl Socket {
6767
// this option, however, was added in 2.6.27, and we still support
6868
// 2.6.18 as a kernel, so if the returned error is EINVAL we
6969
// fallthrough to the fallback.
70-
if cfg!(linux) {
70+
if cfg!(target_os = "linux") {
7171
match cvt(libc::socket(fam, ty | SOCK_CLOEXEC, 0)) {
7272
Ok(fd) => return Ok(Socket(FileDesc::new(fd))),
7373
Err(ref e) if e.raw_os_error() == Some(libc::EINVAL) => {}
@@ -87,7 +87,7 @@ impl Socket {
8787
let mut fds = [0, 0];
8888

8989
// Like above, see if we can set cloexec atomically
90-
if cfg!(linux) {
90+
if cfg!(target_os = "linux") {
9191
match cvt(libc::socketpair(fam, ty | SOCK_CLOEXEC, 0, fds.as_mut_ptr())) {
9292
Ok(_) => {
9393
return Ok((Socket(FileDesc::new(fds[0])), Socket(FileDesc::new(fds[1]))));

0 commit comments

Comments
 (0)