When getaddrinfo returns EAI_SYSTEM retrieve actual error from errno.
Fixes issue #36546. This change also updates libc to earliest version that includes EAI_SYSTEM constant.
This commit is contained in:
parent
3bf4a7ad45
commit
c52b957b89
2 changed files with 8 additions and 3 deletions
|
@ -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;
|
||||
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue