summaryrefslogtreecommitdiffstats
path: root/net/base/host_resolver.cc
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-17 04:16:25 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-17 04:16:25 +0000
commit061efec5fa1af222d72b887feb5788260cb5248f (patch)
tree83317a4b942609b17398cc74fa1caea172443683 /net/base/host_resolver.cc
parent2aecf73871ce89098c0f2f6dd61d6adfe1f059ee (diff)
downloadchromium_src-061efec5fa1af222d72b887feb5788260cb5248f.zip
chromium_src-061efec5fa1af222d72b887feb5788260cb5248f.tar.gz
chromium_src-061efec5fa1af222d72b887feb5788260cb5248f.tar.bz2
Re-land final subset of r18520.
The original code review that this belongs to is: <http://codereview.chromium.org/125171>. (BUG=14138) The original was backed out because of a valgrind linux error (BUG=14218), so I relanded it in smaller chunks to see at which point problem happens. This differs from the original, in that I have changed the unit-test to no longer use ScopedMapper + WaitingMapper, which I believe was the source of a race. Review URL: http://codereview.chromium.org/125232 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18587 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/host_resolver.cc')
-rw-r--r--net/base/host_resolver.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/net/base/host_resolver.cc b/net/base/host_resolver.cc
index d834eb1..ca742da 100644
--- a/net/base/host_resolver.cc
+++ b/net/base/host_resolver.cc
@@ -289,6 +289,7 @@ class HostResolver::Job : public base::RefCountedThreadSafe<HostResolver::Job> {
// Cancels the current job. Callable from origin thread.
void Cancel() {
+ HostResolver* resolver = resolver_;
resolver_ = NULL;
// Mark the job as cancelled, so when worker thread completes it will
@@ -297,6 +298,17 @@ class HostResolver::Job : public base::RefCountedThreadSafe<HostResolver::Job> {
AutoLock locked(origin_loop_lock_);
origin_loop_ = NULL;
}
+
+ // We don't have to do anything further to actually cancel the requests
+ // that were attached to this job (since they are unreachable now).
+ // But we will call HostResolver::CancelRequest(Request*) on each one
+ // in order to notify any observers.
+ for (RequestsList::const_iterator it = requests_.begin();
+ it != requests_.end(); ++it) {
+ HostResolver::Request* req = *it;
+ if (!req->was_cancelled())
+ resolver->CancelRequest(req);
+ }
}
// Called from origin thread.
@@ -394,7 +406,7 @@ HostResolver::HostResolver(int max_cache_entries, int cache_duration_ms)
HostResolver::~HostResolver() {
// Cancel the outstanding jobs. Those jobs may contain several attached
- // requests, which will now never be completed.
+ // requests, which will also be cancelled.
for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ++it)
it->second->Cancel();