Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: runtime/bin/socket_win.cc

Issue 246843005: Use AI_ADDRCONFIG on Windows as well. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/builtin.h" 8 #include "bin/builtin.h"
9 #include "bin/eventhandler.h" 9 #include "bin/eventhandler.h"
10 #include "bin/file.h" 10 #include "bin/file.h"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 Initialize(); 226 Initialize();
227 227
228 // getaddrinfo is not thread-safe on Windows. Use a mutex to get around it. 228 // getaddrinfo is not thread-safe on Windows. Use a mutex to get around it.
229 MutexLocker locker(getaddrinfo_mutex); 229 MutexLocker locker(getaddrinfo_mutex);
230 230
231 // Perform a name lookup for a host name. 231 // Perform a name lookup for a host name.
232 struct addrinfo hints; 232 struct addrinfo hints;
233 memset(&hints, 0, sizeof(hints)); 233 memset(&hints, 0, sizeof(hints));
234 hints.ai_family = SocketAddress::FromType(type); 234 hints.ai_family = SocketAddress::FromType(type);
235 hints.ai_socktype = SOCK_STREAM; 235 hints.ai_socktype = SOCK_STREAM;
236 hints.ai_flags = 0; 236 hints.ai_flags = (AI_V4MAPPED | AI_ADDRCONFIG);
237 hints.ai_protocol = IPPROTO_TCP; 237 hints.ai_protocol = IPPROTO_TCP;
238 struct addrinfo* info = NULL; 238 struct addrinfo* info = NULL;
239 int status = getaddrinfo(host, 0, &hints, &info); 239 int status = getaddrinfo(host, 0, &hints, &info);
240 if (status != 0) { 240 if (status != 0) {
241 // We failed, try without AI_ADDRCONFIG. This can happen when looking up
242 // e.g. '::1', when there are no global IPv6 addresses.
243 hints.ai_flags = AI_V4MAPPED;
244 status = getaddrinfo(host, 0, &hints, &info);
245 }
246 if (status != 0) {
241 ASSERT(*os_error == NULL); 247 ASSERT(*os_error == NULL);
242 DWORD error_code = WSAGetLastError(); 248 DWORD error_code = WSAGetLastError();
243 SetLastError(error_code); 249 SetLastError(error_code);
244 *os_error = new OSError(); 250 *os_error = new OSError();
245 return NULL; 251 return NULL;
246 } 252 }
247 intptr_t count = 0; 253 intptr_t count = 0;
248 for (struct addrinfo* c = info; c != NULL; c = c->ai_next) { 254 for (struct addrinfo* c = info; c != NULL; c = c->ai_next) {
249 if (c->ai_family == AF_INET || c->ai_family == AF_INET6) count++; 255 if (c->ai_family == AF_INET || c->ai_family == AF_INET6) count++;
250 } 256 }
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 proto, 647 proto,
642 MCAST_LEAVE_GROUP, 648 MCAST_LEAVE_GROUP,
643 reinterpret_cast<char *>(&mreq), 649 reinterpret_cast<char *>(&mreq),
644 sizeof(mreq)) == 0; 650 sizeof(mreq)) == 0;
645 } 651 }
646 652
647 } // namespace bin 653 } // namespace bin
648 } // namespace dart 654 } // namespace dart
649 655
650 #endif // defined(TARGET_OS_WINDOWS) 656 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698