Skip to content

Commit bdf610c

Browse files
committed
Return empty list on EAI_ errors for getaddrinfo@luv (ocaml-multicore#351)
Unix.getaddrinfo used in u-ring ignores gar_errno and returns an empty list, this makes the luv backend follow a similar behaviour.
1 parent 7cb0da3 commit bdf610c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Diff for: lib_eio_luv/eio_luv.ml

+9-4
Original file line numberDiff line numberDiff line change
@@ -575,10 +575,15 @@ module Low_level = struct
575575
| _ -> None
576576
in
577577
let request = Luv.DNS.Addr_info.Request.make () in
578-
await_with_cancel ~request (fun loop -> Luv.DNS.getaddrinfo ~loop ~request ~service ~node ())
579-
|> or_raise
580-
|> List.filter_map to_eio_sockaddr_t
581-
578+
match (await_with_cancel ~request
579+
(fun loop -> Luv.DNS.getaddrinfo ~loop ~request ~service ~node ()))
580+
with
581+
| Ok nl -> List.filter_map to_eio_sockaddr_t nl
582+
| Error `EAI_ADDRFAMILY | Error `EAI_AGAIN | Error `EAI_BADFLAGS | Error `EAI_BADHINTS
583+
| Error `EAI_CANCELED | Error `EAI_FAIL | Error `EAI_FAMILY | Error `EAI_MEMORY
584+
| Error `EAI_NODATA | Error `EAI_NONAME| Error `EAI_OVERFLOW | Error `EAI_PROTOCOL
585+
| Error `EAI_SERVICE | Error `EAI_SOCKTYPE -> []
586+
| Error e -> raise (Luv_error e)
582587
end
583588

584589
open Low_level

0 commit comments

Comments
 (0)