Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/dns/dns_config_service_posix.h" | 5 #include "net/dns/dns_config_service_posix.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 // A SerialWorker that uses ResolverLib to initialize res_state and converts | 24 // A SerialWorker that uses ResolverLib to initialize res_state and converts |
| 25 // it to DnsConfig. | 25 // it to DnsConfig. |
| 26 class DnsConfigServicePosix::ConfigReader : public SerialWorker { | 26 class DnsConfigServicePosix::ConfigReader : public SerialWorker { |
| 27 public: | 27 public: |
| 28 explicit ConfigReader(DnsConfigServicePosix* service) | 28 explicit ConfigReader(DnsConfigServicePosix* service) |
| 29 : service_(service), | 29 : service_(service), |
| 30 success_(false) {} | 30 success_(false) {} |
| 31 | 31 |
| 32 void DoWork() OVERRIDE { | 32 void DoWork() OVERRIDE { |
| 33 #if defined(OS_OPENBSD) | |
| 34 extern struct __res_state _res; | |
|
wtc
2011/10/18 21:50:26
Is the _res global variable not declared in any sy
Robert Nagy
2011/10/19 07:10:02
It is in resolv.h so I removed the declaration fro
| |
| 35 if ((res_init() == 0) && (_res.options & RES_INIT)) { | |
| 36 success_ = ConvertResToConfig(_res, &dns_config_); | |
| 37 #else | |
| 33 struct __res_state res; | 38 struct __res_state res; |
| 34 if ((res_ninit(&res) == 0) && (res.options & RES_INIT)) { | 39 if ((res_ninit(&res) == 0) && (res.options & RES_INIT)) { |
| 35 success_ = ConvertResToConfig(res, &dns_config_); | 40 success_ = ConvertResToConfig(res, &dns_config_); |
| 41 #endif | |
| 36 } else { | 42 } else { |
| 37 // Note: res_ninit in glibc always returns 0 and sets RES_INIT. | 43 // Note: res_ninit in glibc always returns 0 and sets RES_INIT. |
| 38 success_ = false; | 44 success_ = false; |
| 39 } | 45 } |
| 40 #if defined(OS_MACOSX) | 46 #if defined(OS_MACOSX) |
| 41 res_ndestroy(&res); | 47 res_ndestroy(&res); |
| 42 #else | 48 #elif !defined(OS_OPENBSD) |
| 43 res_nclose(&res); | 49 res_nclose(&res); |
| 44 #endif | 50 #endif |
| 45 } | 51 } |
| 46 | 52 |
| 47 void OnWorkFinished() OVERRIDE { | 53 void OnWorkFinished() OVERRIDE { |
| 48 DCHECK(!IsCancelled()); | 54 DCHECK(!IsCancelled()); |
| 49 if (success_) | 55 if (success_) |
| 50 service_->OnConfigRead(dns_config_); | 56 service_->OnConfigRead(dns_config_); |
| 51 } | 57 } |
| 52 | 58 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 } | 122 } |
| 117 | 123 |
| 118 dns_config->search.clear(); | 124 dns_config->search.clear(); |
| 119 for (int i = 0; (i < MAXDNSRCH) && res.dnsrch[i]; ++i) { | 125 for (int i = 0; (i < MAXDNSRCH) && res.dnsrch[i]; ++i) { |
| 120 dns_config->search.push_back(std::string(res.dnsrch[i])); | 126 dns_config->search.push_back(std::string(res.dnsrch[i])); |
| 121 } | 127 } |
| 122 | 128 |
| 123 dns_config->ndots = res.ndots; | 129 dns_config->ndots = res.ndots; |
| 124 dns_config->timeout = base::TimeDelta::FromSeconds(res.retrans); | 130 dns_config->timeout = base::TimeDelta::FromSeconds(res.retrans); |
| 125 dns_config->attempts = res.retry; | 131 dns_config->attempts = res.retry; |
| 132 #if !defined(OS_OPENBSD) | |
| 126 dns_config->rotate = res.options & RES_ROTATE; | 133 dns_config->rotate = res.options & RES_ROTATE; |
| 134 #endif | |
|
wtc
2011/10/18 21:50:26
If RES_ROTATE is defined as a macro on all platfor
Robert Nagy
2011/10/19 07:10:02
Done.
| |
| 127 dns_config->edns0 = res.options & RES_USE_EDNS0; | 135 dns_config->edns0 = res.options & RES_USE_EDNS0; |
| 128 | 136 |
| 129 return true; | 137 return true; |
| 130 } | 138 } |
| 131 | 139 |
| 132 } // namespace net | 140 } // namespace net |
| OLD | NEW |