Chromium Code Reviews| Index: runtime/bin/socket_android.cc |
| diff --git a/runtime/bin/socket_android.cc b/runtime/bin/socket_android.cc |
| index 0ab6af4fda328719a55198da06a71f9930a1647d..6a2d6cee5661bee88a2427c5f8523ee9bf0fe4dd 100644 |
| --- a/runtime/bin/socket_android.cc |
| +++ b/runtime/bin/socket_android.cc |
| @@ -238,16 +238,22 @@ AddressList<SocketAddress>* Socket::LookupAddress(const char* host, |
| memset(&hints, 0, sizeof(hints)); |
| hints.ai_family = SocketAddress::FromType(type); |
| hints.ai_socktype = SOCK_STREAM; |
| - hints.ai_flags = 0; |
| + hints.ai_flags = (AI_V4MAPPED | AI_ADDRCONFIG); |
|
Søren Gjesse
2014/02/17 08:01:38
Looking at the getaddrinfo man page this is the de
|
| hints.ai_protocol = IPPROTO_TCP; |
| struct addrinfo* info = NULL; |
| int status = getaddrinfo(host, 0, &hints, &info); |
| if (status != 0) { |
| - ASSERT(*os_error == NULL); |
| - *os_error = new OSError(status, |
| - gai_strerror(status), |
| - OSError::kGetAddressInfo); |
| - return NULL; |
| + // We failed, try without AI_ADDRCONFIG. This can happen when looking up |
| + // e.g. '::1', when there are no IPv6 addresses. |
| + hints.ai_flags = AI_V4MAPPED; |
| + status = getaddrinfo(host, 0, &hints, &info); |
| + if (status != 0) { |
| + ASSERT(*os_error == NULL); |
| + *os_error = new OSError(status, |
| + gai_strerror(status), |
| + OSError::kGetAddressInfo); |
| + return NULL; |
| + } |
| } |
| intptr_t count = 0; |
| for (struct addrinfo* c = info; c != NULL; c = c->ai_next) { |