diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-07 07:51:16 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-07 07:51:16 +0000 |
commit | 6c710ee20601c5afeb56404982069b6d3975fe91 (patch) | |
tree | f1b47f3443bdb375614b69175c764c831306586d /net | |
parent | 6b0507b19e93b12330bca55841927cb03d9942a7 (diff) | |
download | chromium_src-6c710ee20601c5afeb56404982069b6d3975fe91.zip chromium_src-6c710ee20601c5afeb56404982069b6d3975fe91.tar.gz chromium_src-6c710ee20601c5afeb56404982069b6d3975fe91.tar.bz2 |
Attempt to fix a DCHECK failure related to usage of Singletons
and WorkerPool.
Also add a warning for users of WorkerPool that they need to be
very careful about subtle issues.
Also see discussion in http://codereview.chromium.org/1834002/show
TEST=none
BUG=30177
Review URL: http://codereview.chromium.org/2033001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46665 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/host_resolver_impl.cc | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc index 1c97f22..f901144 100644 --- a/net/base/host_resolver_impl.cc +++ b/net/base/host_resolver_impl.cc @@ -316,6 +316,10 @@ class HostResolverImpl::Job STLDeleteElements(&requests_); } + // WARNING: This code runs inside a worker pool. The shutdown code cannot + // wait for it to finish, so we must be very careful here about using other + // objects (like MessageLoops, Singletons, etc). During shutdown these objects + // may no longer exist. void DoLookup() { if (requests_trace_) { requests_trace_->Add(StringPrintf( @@ -334,20 +338,15 @@ class HostResolverImpl::Job "[resolver thread] Completed job j%d", id_)); } - Task* reply = NewRunnableMethod(this, &Job::OnLookupComplete); - // The origin loop could go away while we are trying to post to it, so we // need to call its PostTask method inside a lock. See ~HostResolver. { AutoLock locked(origin_loop_lock_); if (origin_loop_) { - origin_loop_->PostTask(FROM_HERE, reply); - reply = NULL; + origin_loop_->PostTask(FROM_HERE, + NewRunnableMethod(this, &Job::OnLookupComplete)); } } - - // Does nothing if it got posted. - delete reply; } // Callback for when DoLookup() completes (runs on origin thread). |