eio icon indicating copy to clipboard operation
eio copied to clipboard

Expose getaddrinfo errors. Was: Return empty list on EAI_ errors for getaddrinfo@luv (#351)

Open haesbaert opened this issue 3 years ago • 5 comments

Unix.getaddrinfo used in u-ring ignores gar_errno and returns an empty list, this makes the luv backend follow a similar behaviour.

Should fix #351 where we would get EAI_NONAME (or others) if resolution failed, this is a bit defensive as we just handle expected EAI errors.

haesbaert avatar Oct 20 '22 10:10 haesbaert

cc @patricoferris

haesbaert avatar Oct 20 '22 10:10 haesbaert

Thanks @haesbaert ! This works for me, but I'll differ to @talex5's knowledge of which EAI_ errors to catch and which to no :))

patricoferris avatar Oct 20 '22 14:10 patricoferris

I'll differ to @talex5's knowledge of which EAI_ errors to catch and which to no :))

I have no special knowledge - just reading the getaddrinfo man-page :-)

talex5 avatar Oct 20 '22 14:10 talex5

Some corrections to my previous statement, getaddrinfo(3) cannot return an empty list and no error, it's either something or an error. I checked libc.

This PR should be ~~ready for reviewing~~ (debian is failing, looking into it), some notes:

  • A lot of the stub is just copied from ocaml's stdlib
  • The values chosen for the undefined EAI_* values are taken from libuv (since it works for them it works for us), they're added for completion sakeness and a future guard. I'm sure once we have some other backend those will popup and we will move the stub, or maybe glibc adds them in the future, who knows.
  • The strings for getaddrinfo_error_to_string were copied verbatim from libc.

haesbaert avatar Dec 01 '22 09:12 haesbaert

Tests are zefixed, marking this as ready for review

Another note, I've added the stubs to a new file for two reasons

  • It's too polluting
  • Since it's a lot of copy and paste from stdlib, I have to preserve the copyright. ~~Actually now I noticed EIO's is not GPL, so I should get a clear from Xavier to relicense those bits in EIO~~, forget that, it's LGPL.

haesbaert avatar Dec 01 '22 10:12 haesbaert