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

Side by Side 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: Address comments Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « net/http/http_stream_factory_impl.h ('k') | net/http/http_stream_factory_impl_job_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_stream_factory_impl.h" 5 #include "net/http/http_stream_factory_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <tuple> 8 #include <tuple>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 if (!spdy_session) 243 if (!spdy_session)
244 break; 244 break;
245 const SpdySessionKey& spdy_session_key = spdy_session->spdy_session_key(); 245 const SpdySessionKey& spdy_session_key = spdy_session->spdy_session_key();
246 // Each iteration may empty out the RequestSet for |spdy_session_key| in 246 // Each iteration may empty out the RequestSet for |spdy_session_key| in
247 // |spdy_session_request_map_|. So each time, check for RequestSet and use 247 // |spdy_session_request_map_|. So each time, check for RequestSet and use
248 // the first one. 248 // the first one.
249 // 249 //
250 // TODO(willchan): If it's important, switch RequestSet out for a FIFO 250 // TODO(willchan): If it's important, switch RequestSet out for a FIFO
251 // queue (Order by priority first, then FIFO within same priority). Unclear 251 // queue (Order by priority first, then FIFO within same priority). Unclear
252 // that it matters here. 252 // that it matters here.
253 if (!base::ContainsKey(spdy_session_request_map_, spdy_session_key)) 253 auto iter = spdy_session_request_map_.find(spdy_session_key);
254 if (iter == spdy_session_request_map_.end())
254 break; 255 break;
255 Request* request = *spdy_session_request_map_[spdy_session_key].begin(); 256 Request* request = *iter->second.begin();
256 request->Complete(was_alpn_negotiated, negotiated_protocol, using_spdy); 257 request->Complete(was_alpn_negotiated, negotiated_protocol, using_spdy);
258 RemoveRequestFromSpdySessionRequestMap(request);
257 if (for_websockets_) { 259 if (for_websockets_) {
258 // TODO(ricea): Restore this code path when WebSocket over SPDY 260 // TODO(ricea): Restore this code path when WebSocket over SPDY
259 // implementation is ready. 261 // implementation is ready.
260 NOTREACHED(); 262 NOTREACHED();
261 } else if (request->stream_type() == 263 } else if (request->stream_type() ==
262 HttpStreamRequest::BIDIRECTIONAL_STREAM) { 264 HttpStreamRequest::BIDIRECTIONAL_STREAM) {
263 request->OnBidirectionalStreamImplReady( 265 request->OnBidirectionalStreamImplReady(
264 used_ssl_config, used_proxy_info, 266 used_ssl_config, used_proxy_info,
265 new BidirectionalStreamSpdyImpl(spdy_session, source_dependency)); 267 new BidirectionalStreamSpdyImpl(spdy_session, source_dependency));
266 } else { 268 } else {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 // The number of non-preconnect controllers with a pending main job. 408 // The number of non-preconnect controllers with a pending main job.
407 factory_dump->AddScalar("main_job_count", 409 factory_dump->AddScalar("main_job_count",
408 base::trace_event::MemoryAllocatorDump::kUnitsObjects, 410 base::trace_event::MemoryAllocatorDump::kUnitsObjects,
409 main_job_count); 411 main_job_count);
410 // The number of preconnect controllers. 412 // The number of preconnect controllers.
411 factory_dump->AddScalar("preconnect_count", 413 factory_dump->AddScalar("preconnect_count",
412 base::trace_event::MemoryAllocatorDump::kUnitsObjects, 414 base::trace_event::MemoryAllocatorDump::kUnitsObjects,
413 preconnect_controller_count); 415 preconnect_controller_count);
414 } 416 }
415 417
418 void HttpStreamFactoryImpl::RemoveRequestFromSpdySessionRequestMap(
419 Request* request) {
420 const SpdySessionKey* spdy_session_key = request->spdy_session_key();
421 if (!spdy_session_key)
422 return;
423 auto iter = spdy_session_request_map_.find(*spdy_session_key);
424 if (iter == spdy_session_request_map_.end())
425 return;
426 RequestSet& request_set = iter->second;
427 // erase() is no-op if |request| isn't contained in |request_set|.
428 request_set.erase(request);
429 if (request_set.empty())
430 spdy_session_request_map_.erase(iter);
431 }
432
416 } // namespace net 433 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl.h ('k') | net/http/http_stream_factory_impl_job_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698