OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_POSIX) && !defined(OS_MACOSX) | 9 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
10 #include <resolv.h> | 10 #include <resolv.h> |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // loopback addresses. | 189 // loopback addresses. |
190 if (host_resolver_flags & HOST_RESOLVER_LOOPBACK_ONLY) | 190 if (host_resolver_flags & HOST_RESOLVER_LOOPBACK_ONLY) |
191 hints.ai_flags &= ~AI_ADDRCONFIG; | 191 hints.ai_flags &= ~AI_ADDRCONFIG; |
192 | 192 |
193 if (host_resolver_flags & HOST_RESOLVER_CANONNAME) | 193 if (host_resolver_flags & HOST_RESOLVER_CANONNAME) |
194 hints.ai_flags |= AI_CANONNAME; | 194 hints.ai_flags |= AI_CANONNAME; |
195 | 195 |
196 // Restrict result set to only this socket type to avoid duplicates. | 196 // Restrict result set to only this socket type to avoid duplicates. |
197 hints.ai_socktype = SOCK_STREAM; | 197 hints.ai_socktype = SOCK_STREAM; |
198 | 198 |
| 199 #if WATCH_RESOLV_CONF |
| 200 if (ResolvConfUpdated()) |
| 201 res_ninit(&_res); |
| 202 #endif |
| 203 |
| 204 bool should_retry = false; |
199 int err = getaddrinfo(host.c_str(), NULL, &hints, &ai); | 205 int err = getaddrinfo(host.c_str(), NULL, &hints, &ai); |
200 bool should_retry = false; | 206 #if WATCH_RESOLV_CONF |
201 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) | |
202 // If we fail, re-initialise the resolver just in case there have been any | 207 // If we fail, re-initialise the resolver just in case there have been any |
203 // changes to /etc/resolv.conf and retry. See http://crbug.com/11380 for info. | 208 // changes to /etc/resolv.conf and retry. See http://crbug.com/11380 for info. |
204 if (err && DnsReloadTimerHasExpired()) { | 209 if (err && DnsReloadTimerHasExpired()) { |
205 // When there's no network connection, _res may not be initialized by | 210 // When there's no network connection, _res may not be initialized by |
206 // getaddrinfo. Therefore, we call res_nclose only when there are ns | 211 // getaddrinfo. Therefore, we call res_nclose only when there are ns |
207 // entries. | 212 // entries. |
208 if (_res.nscount > 0) | 213 if (_res.nscount > 0) |
209 res_nclose(&_res); | 214 res_nclose(&_res); |
210 if (!res_ninit(&_res)) | 215 if (!res_ninit(&_res)) |
211 should_retry = true; | 216 should_retry = true; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 #endif | 259 #endif |
255 | 260 |
256 return ERR_NAME_NOT_RESOLVED; | 261 return ERR_NAME_NOT_RESOLVED; |
257 } | 262 } |
258 | 263 |
259 addrlist->Adopt(ai); | 264 addrlist->Adopt(ai); |
260 return OK; | 265 return OK; |
261 } | 266 } |
262 | 267 |
263 } // namespace net | 268 } // namespace net |
OLD | NEW |