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

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

Issue 6033006: Use FileWatcher to watch system resolver config, on systems that require... Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 10 years 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
OLDNEW
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/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
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 #if defined(OS_POSIX) 157 #if defined(OS_POSIX)
158 158
159 void Run() { 159 void Run() {
160 // Runs on a worker thread. 160 // Runs on a worker thread.
161 161
162 if (HandleTestCases()) { 162 if (HandleTestCases()) {
163 Finish(); 163 Finish();
164 return; 164 return;
165 } 165 }
166 166
167 bool need_init = (_res.options & RES_INIT) == 0;
168 #if WATCH_RESOLV_CONF
169 need_init |= ResolvConfUpdated();
170 #endif
171
167 bool r = true; 172 bool r = true;
168 if ((_res.options & RES_INIT) == 0) { 173 if (need_init) {
174 LOG(INFO) << "Initializing resolver";
169 if (res_ninit(&_res) != 0) 175 if (res_ninit(&_res) != 0)
170 r = false; 176 r = false;
171 } 177 }
172 178
173 if (r) { 179 if (r) {
174 unsigned long saved_options = _res.options; 180 unsigned long saved_options = _res.options;
175 r = Do(); 181 r = Do();
176 182
177 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) 183 #if WATCH_RESOLV_CONF
178 if (!r && DnsReloadTimerHasExpired()) { 184 if (!r && DnsReloadTimerHasExpired()) {
179 // When there's no network connection, _res may not be initialized by 185 // When there's no network connection, _res may not be initialized by
180 // getaddrinfo. Therefore, we call res_nclose only when there are ns 186 // getaddrinfo. Therefore, we call res_nclose only when there are ns
181 // entries. 187 // entries.
182 if (_res.nscount > 0) 188 if (_res.nscount > 0)
183 res_nclose(&_res); 189 res_nclose(&_res);
184 if (res_ninit(&_res) == 0) 190 if (res_ninit(&_res) == 0)
185 r = Do(); 191 r = Do();
186 } 192 }
187 #endif 193 #endif
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 inflight_.erase(j); 740 inflight_.erase(j);
735 741
736 job->HandleResult(result, response); 742 job->HandleResult(result, response);
737 delete job; 743 delete job;
738 } 744 }
739 745
740 } // namespace net 746 } // namespace net
741 747
742 DISABLE_RUNNABLE_METHOD_REFCOUNT(net::RRResolverHandle); 748 DISABLE_RUNNABLE_METHOD_REFCOUNT(net::RRResolverHandle);
743 DISABLE_RUNNABLE_METHOD_REFCOUNT(net::RRResolverWorker); 749 DISABLE_RUNNABLE_METHOD_REFCOUNT(net::RRResolverWorker);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698