Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Win: fix uv_getaddrinfo error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed Nov 25, 2011
1 parent 45b976a commit 3a50f8f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/win/getaddrinfo.c
Expand Up @@ -117,15 +117,14 @@ void uv_process_getaddrinfo_req(uv_loop_t* loop, uv_getaddrinfo_t* handle,
struct addrinfo* addrinfo_ptr;
char* alloc_ptr = NULL;
char* cur_ptr = NULL;
uv_err_code uv_ret;
int status = 0;

/* release input parameter memory */
if (handle->alloc != NULL) {
free(handle->alloc);
handle->alloc = NULL;
}

uv_ret = uv_translate_eai_error(handle->retcode);
if (handle->retcode == 0) {
/* convert addrinfoW to addrinfo */
/* first calculate required length */
Expand All @@ -136,7 +135,8 @@ void uv_process_getaddrinfo_req(uv_loop_t* loop, uv_getaddrinfo_t* handle,
if (addrinfow_ptr->ai_canonname != NULL) {
name_len = uv_utf16_to_utf8(addrinfow_ptr->ai_canonname, -1, NULL, 0);
if (name_len == 0) {
uv_ret = uv_translate_sys_error(GetLastError());
uv__set_sys_error(loop, GetLastError());
status = -1;
goto complete;
}
addrinfo_len += ALIGNED_SIZE(name_len);
Expand Down Expand Up @@ -201,9 +201,13 @@ void uv_process_getaddrinfo_req(uv_loop_t* loop, uv_getaddrinfo_t* handle,
}
}
} else {
uv_ret = UV_ENOMEM;
uv__set_artificial_error(loop, UV_ENOMEM);
status = -1;
}

} else {
/* GetAddrInfo failed */
uv__set_artificial_error(loop, uv_translate_eai_error(handle->retcode));
status = -1;
}

/* return memory to system */
Expand All @@ -214,7 +218,7 @@ void uv_process_getaddrinfo_req(uv_loop_t* loop, uv_getaddrinfo_t* handle,

complete:
/* finally do callback with converted result */
handle->getaddrinfo_cb(handle, uv_ret, (struct addrinfo*)alloc_ptr);
handle->getaddrinfo_cb(handle, status, (struct addrinfo*)alloc_ptr);

uv_unref(loop);
}
Expand Down

0 comments on commit 3a50f8f

Please sign in to comment.