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

Side by Side Diff: net/base/dnsrr_resolver.cc

Issue 7737034: Revert 99677 (didn't help) - Revert 99666 (sync tests started failing on mac10.6: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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 | « net/base/dns_reloader.cc ('k') | net/base/host_resolver_impl.h » ('j') | 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) 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/base/dnsrr_resolver.h" 5 #include "net/base/dnsrr_resolver.h"
6 6
7 #if defined(OS_POSIX) 7 #if defined(OS_POSIX)
8 #include <resolv.h> 8 #include <resolv.h>
9 #endif 9 #endif
10 10
11 #if defined(OS_WIN) 11 #if defined(OS_WIN)
12 #include <windns.h> 12 #include <windns.h>
13 #endif 13 #endif
14 14
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/singleton.h" 16 #include "base/memory/singleton.h"
17 #include "base/message_loop.h" 17 #include "base/message_loop.h"
18 #include "base/stl_util.h" 18 #include "base/stl_util.h"
19 #include "base/string_piece.h" 19 #include "base/string_piece.h"
20 #include "base/synchronization/lock.h" 20 #include "base/synchronization/lock.h"
21 #include "base/task.h" 21 #include "base/task.h"
22 #include "base/threading/worker_pool.h" 22 #include "base/threading/worker_pool.h"
23 #include "net/base/dns_reload_timer.h" 23 #include "net/base/dns_reloader.h"
24 #include "net/base/dns_util.h" 24 #include "net/base/dns_util.h"
25 #include "net/base/net_errors.h" 25 #include "net/base/net_errors.h"
26 26
27 // Life of a query: 27 // Life of a query:
28 // 28 //
29 // DnsRRResolver RRResolverJob RRResolverWorker ... Handle 29 // DnsRRResolver RRResolverJob RRResolverWorker ... Handle
30 // | (origin loop) (worker loop) 30 // | (origin loop) (worker loop)
31 // | 31 // |
32 // Resolve() 32 // Resolve()
33 // |---->-------------------<creates> 33 // |---->-------------------<creates>
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 void Run() { 178 void Run() {
179 // Runs on a worker thread. 179 // Runs on a worker thread.
180 180
181 if (HandleTestCases()) { 181 if (HandleTestCases()) {
182 Finish(); 182 Finish();
183 return; 183 return;
184 } 184 }
185 185
186 bool r = true; 186 bool r = true;
187 #if defined(OS_MACOSX) || defined(OS_OPENBSD)
187 if ((_res.options & RES_INIT) == 0) { 188 if ((_res.options & RES_INIT) == 0) {
188 if (res_ninit(&_res) != 0) 189 if (res_ninit(&_res) != 0)
189 r = false; 190 r = false;
190 } 191 }
192 #else
193 DnsReloaderMaybeReload();
194 #endif
191 195
192 if (r) { 196 if (r) {
193 unsigned long saved_options = _res.options; 197 unsigned long saved_options = _res.options;
194 r = Do(); 198 r = Do();
195
196 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
197 if (!r && DnsReloadTimerHasExpired()) {
198 // When there's no network connection, _res may not be initialized by
199 // getaddrinfo. Therefore, we call res_nclose only when there are ns
200 // entries.
201 if (_res.nscount > 0)
202 res_nclose(&_res);
203 if (res_ninit(&_res) == 0)
204 r = Do();
205 }
206 #endif
207 _res.options = saved_options; 199 _res.options = saved_options;
208 } 200 }
209 201
210 response_.fetch_time = base::Time::Now(); 202 response_.fetch_time = base::Time::Now();
211 203
212 if (r) { 204 if (r) {
213 result_ = OK; 205 result_ = OK;
214 } else { 206 } else {
215 result_ = ERR_NAME_NOT_RESOLVED; 207 result_ = ERR_NAME_NOT_RESOLVED;
216 response_.negative = true; 208 response_.negative = true;
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 inflight_.erase(j); 665 inflight_.erase(j);
674 666
675 job->HandleResult(result, response); 667 job->HandleResult(result, response);
676 delete job; 668 delete job;
677 } 669 }
678 670
679 } // namespace net 671 } // namespace net
680 672
681 DISABLE_RUNNABLE_METHOD_REFCOUNT(net::RRResolverHandle); 673 DISABLE_RUNNABLE_METHOD_REFCOUNT(net::RRResolverHandle);
682 DISABLE_RUNNABLE_METHOD_REFCOUNT(net::RRResolverWorker); 674 DISABLE_RUNNABLE_METHOD_REFCOUNT(net::RRResolverWorker);
OLDNEW
« no previous file with comments | « net/base/dns_reloader.cc ('k') | net/base/host_resolver_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698