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

Getaddrinfo raises error on some backends #351

Open
patricoferris opened this issue Oct 19, 2022 · 4 comments · May be fixed by #352
Open

Getaddrinfo raises error on some backends #351

patricoferris opened this issue Oct 19, 2022 · 4 comments · May be fixed by #352
Labels
bug Something isn't working

Comments

@patricoferris
Copy link
Collaborator

It seems that luv raises an exception instead of returning an empty list.

open Eio

let lookup net hostname =
   match Net.getaddrinfo_stream net hostname with
   | [] -> ()
   | _ -> assert false

let () =
  let hostname = "blahblahblah.tarides.com" in
  (assert (Unix.getaddrinfo hostname "" [] = []));
  Eio_main.run (fun env -> lookup env#net hostname)

This returns:

Fatal error: exception Eio_luv.Luv_error(EAI_NONAME) (* unknown node or service *)

I can't currently run this properly on Linux with Uring but I'm assuming it returns [] because Unix.getaddrinfo does.

@haesbaert
Copy link
Contributor

Aye, it returns empty as you expected.
The thing is Unix.getaddrinfo completely ignores errno, it simply checks if it got 0 and then tries to build a list, returning empty if nothing is there.
We should probably do the same, catch all Luv_errors and return an empty list.

haesbaert added a commit to haesbaert/eio that referenced this issue Oct 20, 2022
…#351)

Unix.getaddrinfo used in u-ring ignores gar_errno and returns an empty list, this
makes the luv backend follow a similar behaviour.
haesbaert added a commit to haesbaert/eio that referenced this issue Dec 1, 2022
…#351)

Unix.getaddrinfo used in u-ring ignores gar_errno and returns an empty list, this
makes the luv backend follow a similar behaviour.
@talex5 talex5 added the bug Something isn't working label Feb 6, 2023
@talex5 talex5 mentioned this issue Feb 23, 2023
6 tasks
@talex5 talex5 mentioned this issue Mar 7, 2023
5 tasks
@Sudha247
Copy link
Contributor

Should we close this, now that Eio doesn't have the luv backend anymore?

@talex5 talex5 changed the title Getaddrinfo raises error on eio_luv Getaddrinfo raises error on some backends Sep 27, 2023
@talex5
Copy link
Collaborator

talex5 commented Sep 27, 2023

It also affects eio_posix (I've updated the title).

@joprice
Copy link

joprice commented Jan 24, 2024

I'm hitting an issue via cohttp-eio with a statically compiled binary using musl, where getaddrinfo fails to resolve dns names. I hit this branch https://github.com/mirage/ocaml-cohttp/blob/3cd08e5a34d38a322055390b86f4b5dd6bdc01e7/cohttp-eio/src/client.ml#L82 with the error "failed to resolve hostname". It seems not relying on the glibc getaddrinfo would be nice for this reason as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants