]> git.lizzy.rs Git - rust.git/commitdiff
std: Fix usage of SOCK_CLOEXEC
authorAlex Crichton <alex@alexcrichton.com>
Thu, 21 Jul 2016 00:26:12 +0000 (17:26 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 21 Jul 2016 00:26:12 +0000 (17:26 -0700)
This code path was intended to only get executed on Linux, but unfortunately the
`cfg!` was malformed so it actually never got executed.

src/libstd/sys/unix/net.rs

index a784741c88cc7f3536857065b6490db772e82dc1..6f1b70acb60bc35c3c9f5dfc0cc60c71403bcf76 100644 (file)
@@ -67,7 +67,7 @@ pub fn new_raw(fam: c_int, ty: c_int) -> io::Result<Socket> {
             // this option, however, was added in 2.6.27, and we still support
             // 2.6.18 as a kernel, so if the returned error is EINVAL we
             // fallthrough to the fallback.
-            if cfg!(linux) {
+            if cfg!(target_os = "linux") {
                 match cvt(libc::socket(fam, ty | SOCK_CLOEXEC, 0)) {
                     Ok(fd) => return Ok(Socket(FileDesc::new(fd))),
                     Err(ref e) if e.raw_os_error() == Some(libc::EINVAL) => {}
@@ -87,7 +87,7 @@ pub fn new_pair(fam: c_int, ty: c_int) -> io::Result<(Socket, Socket)> {
             let mut fds = [0, 0];
 
             // Like above, see if we can set cloexec atomically
-            if cfg!(linux) {
+            if cfg!(target_os = "linux") {
                 match cvt(libc::socketpair(fam, ty | SOCK_CLOEXEC, 0, fds.as_mut_ptr())) {
                     Ok(_) => {
                         return Ok((Socket(FileDesc::new(fds[0])), Socket(FileDesc::new(fds[1]))));