Skip to content

Commit

Permalink
When getaddrinfo returns EAI_SYSTEM retrieve actual error from errno.
Browse files Browse the repository at this point in the history
Fixes issue #36546. This change also updates libc to earliest version
that includes EAI_SYSTEM constant.
  • Loading branch information
tmiasko committed Sep 26, 2016
1 parent 3bf4a7a commit c52b957
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/liblibc
Submodule liblibc updated 38 files
+1 −1 Cargo.toml
+1 −1 ci/docker/aarch64-unknown-linux-gnu/Dockerfile
+1 −1 ci/docker/x86_64-unknown-freebsd/Dockerfile
+1 −1 ci/docker/x86_64-unknown-openbsd/Dockerfile
+1 −4 ci/run-qemu.sh
+16 −4 ci/run.sh
+4 −4 libc-test/Cargo.lock
+3 −1 libc-test/build.rs
+63 −29 src/unix/bsd/apple/mod.rs
+50 −0 src/unix/bsd/freebsdlike/dragonfly/mod.rs
+53 −0 src/unix/bsd/freebsdlike/freebsd/mod.rs
+21 −6 src/unix/bsd/freebsdlike/mod.rs
+2 −29 src/unix/bsd/mod.rs
+5 −7 src/unix/bsd/netbsdlike/mod.rs
+40 −12 src/unix/bsd/netbsdlike/netbsd.rs
+75 −0 src/unix/bsd/netbsdlike/openbsdlike/bitrig.rs
+71 −34 src/unix/bsd/netbsdlike/openbsdlike/mod.rs
+28 −0 src/unix/bsd/netbsdlike/openbsdlike/openbsd.rs
+0 −437 src/unix/bsd/openbsdlike/bitrig.rs
+4 −0 src/unix/mod.rs
+61 −0 src/unix/notbsd/android/mod.rs
+26 −0 src/unix/notbsd/linux/mips.rs
+14 −0 src/unix/notbsd/linux/mips64.rs
+34 −1 src/unix/notbsd/linux/mod.rs
+17 −0 src/unix/notbsd/linux/musl/b32/arm.rs
+17 −0 src/unix/notbsd/linux/musl/b32/asmjs.rs
+26 −0 src/unix/notbsd/linux/musl/b32/mips.rs
+17 −0 src/unix/notbsd/linux/musl/b32/x86.rs
+14 −0 src/unix/notbsd/linux/musl/b64/mod.rs
+17 −0 src/unix/notbsd/linux/other/b32/arm.rs
+17 −0 src/unix/notbsd/linux/other/b32/powerpc.rs
+17 −0 src/unix/notbsd/linux/other/b32/x86.rs
+3 −4 src/unix/notbsd/linux/other/b64/aarch64.rs
+14 −0 src/unix/notbsd/linux/other/b64/mod.rs
+63 −0 src/unix/notbsd/linux/other/mod.rs
+3 −0 src/unix/notbsd/mod.rs
+2 −0 src/unix/solaris/mod.rs
+41 −0 src/windows.rs
9 changes: 7 additions & 2 deletions src/libstd/sys/unix/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use ffi::CStr;
use io;
use libc::{self, c_int, size_t, sockaddr, socklen_t};
use libc::{self, c_int, size_t, sockaddr, socklen_t, EAI_SYSTEM};
use net::{SocketAddr, Shutdown};
use str;
use sys::fd::FileDesc;
Expand Down Expand Up @@ -38,7 +38,12 @@ pub struct Socket(FileDesc);
pub fn init() {}

pub fn cvt_gai(err: c_int) -> io::Result<()> {
if err == 0 { return Ok(()) }
if err == 0 {
return Ok(())
}
if err == EAI_SYSTEM {
return Err(io::Error::last_os_error())
}

let detail = unsafe {
str::from_utf8(CStr::from_ptr(libc::gai_strerror(err)).to_bytes()).unwrap()
Expand Down

0 comments on commit c52b957

Please sign in to comment.