Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errno ignored for unix getaddrinfo #36546

Closed
jwilm opened this issue Sep 16, 2016 · 2 comments
Closed

errno ignored for unix getaddrinfo #36546

jwilm opened this issue Sep 16, 2016 · 2 comments

Comments

@jwilm
Copy link

jwilm commented Sep 16, 2016

When getaddrinfo() fails, the wrapper produces a custom io::Error using gai_strerror(). There's one variant which essentially says just look at errno.

EAI_SYSTEM    system error returned in errno

But libstd doesn't do that which leads to very unhelpful errors.

Io(Error { repr: Custom(Custom { kind: Other, error: StringError("failed to lookup address information: System error") }) }))

It would be great if the error value could be checked for EAI_SYSTEM, provide the strerror() message in the StringError value, and set Kind appropriately.

@alexcrichton
Copy link
Member

Sounds reasonable to me! Should hopefully be more tackle-able once rust-lang/libc#402 lands.

sophiajt pushed a commit to sophiajt/rust that referenced this issue Sep 27, 2016
…richton

When getaddrinfo returns EAI_SYSTEM retrieve actual error from errno.

Fixes issue rust-lang#36546. This change also updates libc to earliest version
that includes EAI_SYSTEM constant.

Previously, in cases where `EAI_SYSTEM` has been returned from getaddrinfo, the
resulting `io::Error` would be broadly described as "System error":

    Error { repr: Custom(Custom { kind: Other, error: StringError("failed to lookup address information: System error") }) }

After change a more detailed error is crated based on particular value of
errno, for example:

    Error { repr: Os { code: 64, message: "Machine is not on the network" } }

The only downside is that the prefix "failed to lookup address information" is
no longer included in the error message.
@apasel422
Copy link
Contributor

I think this was closed by #36754.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants