joyent/libuv — Issue #334: getaddrinfo error codes
Author: ErikDubbelboer
Created: 2012-03-04 21:01:10+00:00
State: open

Shouldn't `uv_getaddrinfo()` return the error codes of the underlying `getaddrinfo()` call?

Our application started throwing ENOENT exceptions on dns lookups of `localhost`. It took us a long time to figure out that our application was running out of file descriptors and `getaddrinfo()` was actually throwing an EMFILE error.

This would be a fix but it breaks the dns tests which are still looking for an ENOENT:

diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c
index e93a168..4bae632 100644
--- a/deps/uv/src/unix/core.c
+++ b/deps/uv/src/unix/core.c
@@ -649,7 +649,7 @@ static int uv_getaddrinfo_done(eio_req* req) {
#else
} else if (handle->retcode == EAI_NONAME) {
#endif
- uv__set_sys_error(handle->loop, ENOENT); /* FIXME compatibility hack */
+ uv__set_sys_error(handle->loop, errno);
#if __sun
} else if (handle->retcode == EAI_MEMORY && hostlen >= MAXHOSTNAMELEN) {
uv__set_sys_error(handle->loop, ENOENT);