eio
eio copied to clipboard
Expose getaddrinfo errors. Was: Return empty list on EAI_ errors for getaddrinfo@luv (#351)
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.
cc @patricoferris
Thanks @haesbaert ! This works for me, but I'll differ to @talex5's knowledge of which EAI_ errors to catch and which to no :))
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 :-)
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_stringwere copied verbatim from libc.
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.