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

Unified Diff: net/http/http_stream_factory_impl_job_controller.cc

Issue 2784143003: Fix a potential infinite loop in HttpStreamFactoryImpl when a new SpdySession is established (Closed)
Patch Set: Address comments Created 3 years, 9 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 | « net/http/http_stream_factory_impl_job_controller.h ('k') | net/http/http_stream_factory_impl_request.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_stream_factory_impl_job_controller.cc
diff --git a/net/http/http_stream_factory_impl_job_controller.cc b/net/http/http_stream_factory_impl_job_controller.cc
index ba5e01bb2884ce41cd666d6aaab39e58118bda82..32a9ea00d9027420c9c5b484d9f2b33cb74b141b 100644
--- a/net/http/http_stream_factory_impl_job_controller.cc
+++ b/net/http/http_stream_factory_impl_job_controller.cc
@@ -625,13 +625,16 @@ void HttpStreamFactoryImpl::JobController::SetSpdySessionKey(
return;
DCHECK(request_);
- if (!request_->HasSpdySessionKey()) {
- RequestSet& request_set =
- factory_->spdy_session_request_map_[spdy_session_key];
- DCHECK(!base::ContainsKey(request_set, request_));
- request_set.insert(request_);
- request_->SetSpdySessionKey(spdy_session_key);
- }
+ // Remove old key request mapping if applicable.
+ if (request_->HasSpdySessionKey())
+ factory_->RemoveRequestFromSpdySessionRequestMap(request_);
+
+ // Insert a new mapping for the request.
+ RequestSet& request_set =
+ factory_->spdy_session_request_map_[spdy_session_key];
+ DCHECK(!base::ContainsKey(request_set, request_));
+ request_set.insert(request_);
+ request_->SetSpdySessionKey(spdy_session_key);
}
void HttpStreamFactoryImpl::JobController::
@@ -640,23 +643,7 @@ void HttpStreamFactoryImpl::JobController::
return;
DCHECK(request_);
- RemoveRequestFromSpdySessionRequestMap();
-}
-
-void HttpStreamFactoryImpl::JobController::
- RemoveRequestFromSpdySessionRequestMap() {
- const SpdySessionKey* spdy_session_key = request_->spdy_session_key();
- if (spdy_session_key) {
- SpdySessionRequestMap& spdy_session_request_map =
- factory_->spdy_session_request_map_;
- DCHECK(base::ContainsKey(spdy_session_request_map, *spdy_session_key));
- RequestSet& request_set = spdy_session_request_map[*spdy_session_key];
- DCHECK(base::ContainsKey(request_set, request_));
- request_set.erase(request_);
- if (request_set.empty())
- spdy_session_request_map.erase(*spdy_session_key);
- request_->ResetSpdySessionKey();
- }
+ factory_->RemoveRequestFromSpdySessionRequestMap(request_);
}
const NetLogWithSource* HttpStreamFactoryImpl::JobController::GetNetLog(
@@ -773,7 +760,7 @@ void HttpStreamFactoryImpl::JobController::BindJob(Job* job) {
void HttpStreamFactoryImpl::JobController::CancelJobs() {
DCHECK(request_);
- RemoveRequestFromSpdySessionRequestMap();
+ factory_->RemoveRequestFromSpdySessionRequestMap(request_);
if (job_bound_)
return;
if (alternative_job_) {
@@ -788,7 +775,7 @@ void HttpStreamFactoryImpl::JobController::CancelJobs() {
void HttpStreamFactoryImpl::JobController::OrphanUnboundJob() {
DCHECK(request_);
- RemoveRequestFromSpdySessionRequestMap();
+ factory_->RemoveRequestFromSpdySessionRequestMap(request_);
DCHECK(bound_job_);
if (bound_job_->job_type() == MAIN && alternative_job_) {
« no previous file with comments | « net/http/http_stream_factory_impl_job_controller.h ('k') | net/http/http_stream_factory_impl_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698