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

Unified Diff: net/base/host_resolver_impl.cc

Issue 9572018: [net] Ensure aborted HostResolverImpl::Jobs release slots in the dispatcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/base/host_resolver_impl_unittest.cc » ('j') | net/base/host_resolver_impl_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/host_resolver_impl.cc
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc
index 1e4d757af05ed2d6934e28ae95bafdffc1b125bb..d7a23ded5d411963e9df66521a27ea75ec502f63 100644
--- a/net/base/host_resolver_impl.cc
+++ b/net/base/host_resolver_impl.cc
@@ -1572,8 +1572,10 @@ void HostResolverImpl::CancelRequest(RequestHandle req_handle) {
// that Request could not have been cancelled, so job->num_active_requests()
// could not be 0. Therefore, we are not in Job::CompleteRequests().
RemoveJob(job);
- if (job->is_running())
+ if (job->is_running()) {
+ dispatcher_.OnJobFinished();
cbentzel 2012/03/02 19:05:02 Does the ordering here matter? It's different in t
szym 2012/03/02 19:09:30 I feel that the preferred order is Abort then disp
job->Abort();
+ }
delete job;
}
}
@@ -1724,9 +1726,14 @@ void HostResolverImpl::AbortAllInProgressJobs() {
}
}
+ // Check if no dispatcher slots leaked out.
+ DCHECK_EQ(dispatcher_.num_running_jobs(), jobs_to_abort.size());
+
// Then Abort them and dispatch new Jobs.
for (size_t i = 0; i < jobs_to_abort.size(); ++i) {
jobs_to_abort[i]->Abort();
+ if (!self)
+ break; // |this| got destroyed in a request callback.
dispatcher_.OnJobFinished();
}
STLDeleteElements(&jobs_to_abort);
« no previous file with comments | « no previous file | net/base/host_resolver_impl_unittest.cc » ('j') | net/base/host_resolver_impl_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698