diff options
Diffstat (limited to 'deps/uv/src/unix/getaddrinfo.c')
-rw-r--r-- | deps/uv/src/unix/getaddrinfo.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/deps/uv/src/unix/getaddrinfo.c b/deps/uv/src/unix/getaddrinfo.c index faf9add928..0d684e24e1 100644 --- a/deps/uv/src/unix/getaddrinfo.c +++ b/deps/uv/src/unix/getaddrinfo.c @@ -99,21 +99,17 @@ static void uv__getaddrinfo_work(struct uv__work* w) { int err; req = container_of(w, uv_getaddrinfo_t, work_req); - err = getaddrinfo(req->hostname, req->service, req->hints, &req->res); + err = getaddrinfo(req->hostname, req->service, req->hints, &req->addrinfo); 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; req = container_of(w, uv_getaddrinfo_t, work_req); uv__req_unregister(req->loop, req); - res = req->res; - req->res = NULL; - /* See initialization in uv_getaddrinfo(). */ if (req->hints) free(req->hints); @@ -133,7 +129,8 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) { req->retcode = UV_EAI_CANCELED; } - req->cb(req, req->retcode, res); + if (req->cb) + req->cb(req, req->retcode, req->addrinfo); } @@ -149,7 +146,7 @@ int uv_getaddrinfo(uv_loop_t* loop, size_t len; char* buf; - if (req == NULL || cb == NULL || (hostname == NULL && service == NULL)) + if (req == NULL || (hostname == NULL && service == NULL)) return -EINVAL; hostname_len = hostname ? strlen(hostname) + 1 : 0; @@ -163,7 +160,7 @@ int uv_getaddrinfo(uv_loop_t* loop, uv__req_init(loop, req, UV_GETADDRINFO); req->loop = loop; req->cb = cb; - req->res = NULL; + req->addrinfo = NULL; req->hints = NULL; req->service = NULL; req->hostname = NULL; @@ -185,12 +182,17 @@ int uv_getaddrinfo(uv_loop_t* loop, if (hostname) req->hostname = memcpy(buf + len, hostname, hostname_len); - uv__work_submit(loop, - &req->work_req, - uv__getaddrinfo_work, - uv__getaddrinfo_done); - - return 0; + if (cb) { + uv__work_submit(loop, + &req->work_req, + uv__getaddrinfo_work, + uv__getaddrinfo_done); + return 0; + } else { + uv__getaddrinfo_work(&req->work_req); + uv__getaddrinfo_done(&req->work_req, 0); + return req->retcode; + } } |