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); |