The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

eio_windows: work around problems in Unix.getaddrinfo

OCaml's `Unix.getaddrinfo` on Windows doesn't set `ai_protocol` to
anything useful, so you can't tell which addresses are TCP and which are
UDP. So, do two separate queries.

+12 -13
+12 -13
vendor/opam/eio/lib_eio_windows/net.ml
··· 83 83 let datagram_socket fd = 84 84 Eio.Resource.T (fd, datagram_handler) 85 85 86 - (* https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml *) 87 86 let getaddrinfo ~service node = 88 - let to_eio_sockaddr_t {Unix.ai_family; ai_addr; ai_socktype; ai_protocol; _ } = 89 - match ai_family, ai_socktype, ai_addr with 90 - | (Unix.PF_INET | PF_INET6), 91 - (Unix.SOCK_STREAM | SOCK_DGRAM), 92 - Unix.ADDR_INET (inet_addr,port) -> ( 93 - match ai_protocol with 94 - | 6 -> Some (`Tcp (Eio_unix.Net.Ipaddr.of_unix inet_addr, port)) 95 - | 17 -> Some (`Udp (Eio_unix.Net.Ipaddr.of_unix inet_addr, port)) 96 - | _ -> None) 97 - | _ -> None 87 + (* OCaml's [Unix.getaddrinfo] on Windows doesn't set [ai_protocol] to 88 + anything useful, so you can't tell which addresses are TCP and which are 89 + UDP. So, do two separate queries. *) 90 + let get ty k = 91 + Unix.getaddrinfo node service [AI_SOCKTYPE ty] 92 + |> List.filter_map (function 93 + | {Unix.ai_addr = ADDR_INET (host, port); _} -> 94 + Some (k (Eio_unix.Net.Ipaddr.of_unix host, port)) 95 + | _ -> None 96 + ) 98 97 in 99 98 Err.run (Eio_unix.run_in_systhread ~label:"getaddrinfo") @@ fun () -> 100 99 let rec aux () = 101 100 try 102 - Unix.getaddrinfo node service [] 103 - |> List.filter_map to_eio_sockaddr_t 101 + get SOCK_STREAM (fun x -> `Tcp x) @ 102 + get SOCK_DGRAM (fun x -> `Udp x) 104 103 with Unix.Unix_error (EINTR, _, _) -> aux () 105 104 in 106 105 aux ()