summaryrefslogtreecommitdiff
path: root/deps/uv/src/unix/getaddrinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'deps/uv/src/unix/getaddrinfo.c')
-rw-r--r--deps/uv/src/unix/getaddrinfo.c51
1 files changed, 10 insertions, 41 deletions
diff --git a/deps/uv/src/unix/getaddrinfo.c b/deps/uv/src/unix/getaddrinfo.c
index 994e0f3816..1db00680d1 100644
--- a/deps/uv/src/unix/getaddrinfo.c
+++ b/deps/uv/src/unix/getaddrinfo.c
@@ -28,19 +28,18 @@
static void uv__getaddrinfo_work(struct uv__work* w) {
- uv_getaddrinfo_t* req = container_of(w, uv_getaddrinfo_t, work_req);
+ uv_getaddrinfo_t* req;
+ int err;
- req->retcode = getaddrinfo(req->hostname,
- req->service,
- req->hints,
- &req->res);
+ req = container_of(w, uv_getaddrinfo_t, work_req);
+ err = getaddrinfo(req->hostname, req->service, req->hints, &req->res);
+ req->retcode = uv__getaddrinfo_translate_error(err);
}
static void uv__getaddrinfo_done(struct uv__work* w, int status) {
uv_getaddrinfo_t* req;
struct addrinfo *res;
- size_t hostlen;
req = container_of(w, uv_getaddrinfo_t, work_req);
uv__req_unregister(req->loop, req);
@@ -48,13 +47,6 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) {
res = req->res;
req->res = NULL;
- (void) &hostlen; /* Silence unused variable warning. */
- hostlen = 0;
-#if defined(__sun)
- if (req->hostname != NULL)
- hostlen = strlen(req->hostname);
-#endif
-
/* See initialization in uv_getaddrinfo(). */
if (req->hints)
free(req->hints);
@@ -69,35 +61,12 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) {
req->service = NULL;
req->hostname = NULL;
- if (status == -UV_ECANCELED) {
+ if (status == -ECANCELED) {
assert(req->retcode == 0);
- req->retcode = UV_ECANCELED;
- uv__set_artificial_error(req->loop, UV_ECANCELED);
- req->cb(req, -1, NULL);
- return;
- }
-
- if (req->retcode == 0) {
- req->cb(req, 0, res);
- return;
- }
-
- if (req->retcode == EAI_NONAME)
- uv__set_sys_error(req->loop, ENOENT);
-#if defined(EAI_NODATA) /* Newer FreeBSDs don't have EAI_NODATA. */
- else if (req->retcode == EAI_NODATA)
- uv__set_sys_error(req->loop, ENOENT);
-#endif
-#if defined(__sun)
- else if (req->retcode == EAI_MEMORY && hostlen >= MAXHOSTNAMELEN)
- uv__set_sys_error(req->loop, ENOENT);
-#endif
- else {
- req->loop->last_err.code = UV_EADDRINFO;
- req->loop->last_err.sys_errno_ = req->retcode;
+ req->retcode = UV_EAI_CANCELED;
}
- req->cb(req, -1, res);
+ req->cb(req, req->retcode, res);
}
@@ -114,7 +83,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
char* buf;
if (req == NULL || cb == NULL || (hostname == NULL && service == NULL))
- return uv__set_artificial_error(loop, UV_EINVAL);
+ return -EINVAL;
hostname_len = hostname ? strlen(hostname) + 1 : 0;
service_len = service ? strlen(service) + 1 : 0;
@@ -122,7 +91,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
buf = malloc(hostname_len + service_len + hints_len);
if (buf == NULL)
- return uv__set_artificial_error(loop, UV_ENOMEM);
+ return -ENOMEM;
uv__req_init(loop, req, UV_GETADDRINFO);
req->loop = loop;