Skip to content

Commit

Permalink
Return empty list on EAI_ errors for getaddrinfo@luv (ocaml-multicore…
Browse files Browse the repository at this point in the history
…#351)

Unix.getaddrinfo used in u-ring ignores gar_errno and returns an empty list, this
makes the luv backend follow a similar behaviour.
  • Loading branch information
haesbaert committed Dec 1, 2022
1 parent eb4d9ed commit 2e09d49
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib_eio_luv/eio_luv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -654,10 +654,15 @@ module Low_level = struct
| _ -> None
in
let request = Luv.DNS.Addr_info.Request.make () in
await_with_cancel ~request (fun loop -> Luv.DNS.getaddrinfo ~loop ~request ~service ~node ())
|> or_raise
|> List.filter_map to_eio_sockaddr_t

match (await_with_cancel ~request
(fun loop -> Luv.DNS.getaddrinfo ~loop ~request ~service ~node ()))
with
| Ok nl -> List.filter_map to_eio_sockaddr_t nl
| Error `EAI_ADDRFAMILY | Error `EAI_AGAIN | Error `EAI_BADFLAGS | Error `EAI_BADHINTS
| Error `EAI_CANCELED | Error `EAI_FAIL | Error `EAI_FAMILY | Error `EAI_MEMORY
| Error `EAI_NODATA | Error `EAI_NONAME| Error `EAI_OVERFLOW | Error `EAI_PROTOCOL
| Error `EAI_SERVICE | Error `EAI_SOCKTYPE -> []
| Error e -> raise (Luv_error e)
end

open Low_level
Expand Down

0 comments on commit 2e09d49

Please sign in to comment.