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

Unified Diff: net/http/http_stream_factory_impl.cc

Issue 2784143003: Fix a potential infinite loop in HttpStreamFactoryImpl when a new SpdySession is established (Closed)
Patch Set: rebased 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
Index: net/http/http_stream_factory_impl.cc
diff --git a/net/http/http_stream_factory_impl.cc b/net/http/http_stream_factory_impl.cc
index bfd8303bc3f29cc8126b87411fe8168bacf42380..44efbc680e1ffcadc35e869f2d6a094410f2909d 100644
--- a/net/http/http_stream_factory_impl.cc
+++ b/net/http/http_stream_factory_impl.cc
@@ -254,6 +254,7 @@ void HttpStreamFactoryImpl::OnNewSpdySessionReady(
break;
Request* request = *spdy_session_request_map_[spdy_session_key].begin();
request->Complete(was_alpn_negotiated, negotiated_protocol, using_spdy);
+ RemoveRequestFromSpdySessionRequestMap(request);
if (for_websockets_) {
// TODO(ricea): Restore this code path when WebSocket over SPDY
// implementation is ready.
@@ -413,4 +414,18 @@ void HttpStreamFactoryImpl::DumpMemoryStats(
preconnect_controller_count);
}
+void HttpStreamFactoryImpl::RemoveRequestFromSpdySessionRequestMap(
+ Request* request) {
+ const SpdySessionKey* spdy_session_key = request->spdy_session_key();
+ if (!spdy_session_key)
+ return;
+ if (!base::ContainsKey(spdy_session_request_map_, *spdy_session_key))
Bence 2017/03/31 16:21:27 Please use |iterator it = find(*spdy_session_key);
xunjieli 2017/03/31 17:45:26 Done.
+ return;
+ RequestSet& request_set = spdy_session_request_map_[*spdy_session_key];
+ if (base::ContainsKey(request_set, request))
Bence 2017/03/31 16:21:27 Skip the ContainsKey() call in order to avoid doin
xunjieli 2017/03/31 17:45:26 Done.
+ request_set.erase(request);
+ if (request_set.empty())
+ spdy_session_request_map_.erase(*spdy_session_key);
Bence 2017/03/31 16:21:27 And use the iterator here to avoid the third looku
xunjieli 2017/03/31 17:45:26 Done. Good idea!
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698