Skip to content

src: cares_wrap: only loop through once on lookup #4693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions src/cares_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
char ip[INET6_ADDRSTRLEN];
const char *addr;

// Iterate over the IPv4 responses again this time creating javascript
// Iterate over the IPv4/IPv6 responses again this time creating javascript
// strings for each IP and filling the results array.
address = res;
while (address) {
Expand All @@ -950,20 +950,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
Local<String> s = OneByteString(env->isolate(), ip);
results->Set(n, s);
n++;
}

// Increment
address = address->ai_next;
}

// Iterate over the IPv6 responses putting them in the array.
address = res;
while (address) {
CHECK_EQ(address->ai_socktype, SOCK_STREAM);

// Ignore random ai_family types.
if (address->ai_family == AF_INET6) {
// Juggle pointers
} else if (address->ai_family == AF_INET6) {
addr = reinterpret_cast<char*>(&(reinterpret_cast<struct sockaddr_in6*>(
address->ai_addr)->sin6_addr));
int err = uv_inet_ntop(address->ai_family,
Expand Down