OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/base/host_resolver_proc.h" | 5 #include "net/base/host_resolver_proc.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <ws2tcpip.h> | 10 #include <ws2tcpip.h> |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 DISALLOW_COPY_AND_ASSIGN(DnsReloadTimer); | 118 DISALLOW_COPY_AND_ASSIGN(DnsReloadTimer); |
119 }; | 119 }; |
120 | 120 |
121 // A TLS slot to the TimeTicks for the current thread. | 121 // A TLS slot to the TimeTicks for the current thread. |
122 // static | 122 // static |
123 ThreadLocalStorage::Slot DnsReloadTimer::tls_index_(base::LINKER_INITIALIZED); | 123 ThreadLocalStorage::Slot DnsReloadTimer::tls_index_(base::LINKER_INITIALIZED); |
124 | 124 |
125 #endif // defined(OS_LINUX) | 125 #endif // defined(OS_LINUX) |
126 | 126 |
127 int SystemHostResolverProc(const std::string& host, AddressList* addrlist) { | 127 int SystemHostResolverProc(const std::string& host, AddressList* addrlist) { |
| 128 // The result of |getaddrinfo| for empty hosts is inconsistent across systems. |
| 129 // On Windows it gives the default interface's address, whereas on Linux it |
| 130 // gives an error. We will make it fail on all platforms for consistency. |
| 131 if (host.empty()) |
| 132 return ERR_NAME_NOT_RESOLVED; |
| 133 |
128 struct addrinfo* ai = NULL; | 134 struct addrinfo* ai = NULL; |
129 struct addrinfo hints = {0}; | 135 struct addrinfo hints = {0}; |
130 hints.ai_family = AF_UNSPEC; | 136 hints.ai_family = AF_UNSPEC; |
131 | 137 |
132 #if defined(OS_WIN) | 138 #if defined(OS_WIN) |
133 // DO NOT USE AI_ADDRCONFIG ON WINDOWS. | 139 // DO NOT USE AI_ADDRCONFIG ON WINDOWS. |
134 // | 140 // |
135 // The following comment in <winsock2.h> is the best documentation I found | 141 // The following comment in <winsock2.h> is the best documentation I found |
136 // on AI_ADDRCONFIG for Windows: | 142 // on AI_ADDRCONFIG for Windows: |
137 // Flags used in "hints" argument to getaddrinfo() | 143 // Flags used in "hints" argument to getaddrinfo() |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 #endif | 177 #endif |
172 | 178 |
173 if (err) | 179 if (err) |
174 return ERR_NAME_NOT_RESOLVED; | 180 return ERR_NAME_NOT_RESOLVED; |
175 | 181 |
176 addrlist->Adopt(ai); | 182 addrlist->Adopt(ai); |
177 return OK; | 183 return OK; |
178 } | 184 } |
179 | 185 |
180 } // namespace net | 186 } // namespace net |
OLD | NEW |