From 6c710ee20601c5afeb56404982069b6d3975fe91 Mon Sep 17 00:00:00 2001 From: "phajdan.jr@chromium.org" Date: Fri, 7 May 2010 07:51:16 +0000 Subject: 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 --- net/base/host_resolver_impl.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'net') 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). -- cgit v1.1