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

Side by Side Diff: net/spdy/spdy_session.cc

Issue 287063003: Correct SpdySession StreamID exhaustion behavior (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment tweaks. Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_unittest.cc » ('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/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "net/ssl/server_bound_cert_service.h" 42 #include "net/ssl/server_bound_cert_service.h"
43 43
44 namespace net { 44 namespace net {
45 45
46 namespace { 46 namespace {
47 47
48 const int kReadBufferSize = 8 * 1024; 48 const int kReadBufferSize = 8 * 1024;
49 const int kDefaultConnectionAtRiskOfLossSeconds = 10; 49 const int kDefaultConnectionAtRiskOfLossSeconds = 10;
50 const int kHungIntervalSeconds = 10; 50 const int kHungIntervalSeconds = 10;
51 51
52 // Always start at 1 for the first stream id. 52 // As we always act as the client, start at 1 for the first stream id.
53 const SpdyStreamId kFirstStreamId = 1; 53 const SpdyStreamId kFirstStreamId = 1;
54 const SpdyStreamId kLastStreamId = 0x7fffffff;
54 55
55 // Minimum seconds that unclaimed pushed streams will be kept in memory. 56 // Minimum seconds that unclaimed pushed streams will be kept in memory.
56 const int kMinPushedStreamLifetimeSeconds = 300; 57 const int kMinPushedStreamLifetimeSeconds = 300;
57 58
58 scoped_ptr<base::ListValue> SpdyHeaderBlockToListValue( 59 scoped_ptr<base::ListValue> SpdyHeaderBlockToListValue(
59 const SpdyHeaderBlock& headers, 60 const SpdyHeaderBlock& headers,
60 net::NetLog::LogLevel log_level) { 61 net::NetLog::LogLevel log_level) {
61 scoped_ptr<base::ListValue> headers_list(new base::ListValue()); 62 scoped_ptr<base::ListValue> headers_list(new base::ListValue());
62 for (SpdyHeaderBlock::const_iterator it = headers.begin(); 63 for (SpdyHeaderBlock::const_iterator it = headers.begin();
63 it != headers.end(); ++it) { 64 it != headers.end(); ++it) {
(...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 CHECK(!stream->IsClosed()); 1378 CHECK(!stream->IsClosed());
1378 1379
1379 // Activate the stream only when sending the SYN_STREAM frame to 1380 // Activate the stream only when sending the SYN_STREAM frame to
1380 // guarantee monotonically-increasing stream IDs. 1381 // guarantee monotonically-increasing stream IDs.
1381 if (frame_type == SYN_STREAM) { 1382 if (frame_type == SYN_STREAM) {
1382 CHECK(stream.get()); 1383 CHECK(stream.get());
1383 CHECK_EQ(stream->stream_id(), 0u); 1384 CHECK_EQ(stream->stream_id(), 0u);
1384 scoped_ptr<SpdyStream> owned_stream = 1385 scoped_ptr<SpdyStream> owned_stream =
1385 ActivateCreatedStream(stream.get()); 1386 ActivateCreatedStream(stream.get());
1386 InsertActivatedStream(owned_stream.Pass()); 1387 InsertActivatedStream(owned_stream.Pass());
1388
1389 if (stream_hi_water_mark_ > kLastStreamId) {
1390 CHECK_EQ(stream->stream_id(), kLastStreamId);
1391 // We've exhausted the stream ID space, and no new streams may be
1392 // created after this one.
1393 MakeUnavailable();
1394 StartGoingAway(kLastStreamId, ERR_ABORTED);
1395 }
1387 } 1396 }
1388 1397
1389 in_flight_write_ = producer->ProduceBuffer(); 1398 in_flight_write_ = producer->ProduceBuffer();
1390 if (!in_flight_write_) { 1399 if (!in_flight_write_) {
1391 NOTREACHED(); 1400 NOTREACHED();
1392 return ERR_UNEXPECTED; 1401 return ERR_UNEXPECTED;
1393 } 1402 }
1394 in_flight_write_frame_type_ = frame_type; 1403 in_flight_write_frame_type_ = frame_type;
1395 in_flight_write_frame_size_ = in_flight_write_->GetRemainingSize(); 1404 in_flight_write_frame_size_ = in_flight_write_->GetRemainingSize();
1396 DCHECK_GE(in_flight_write_frame_size_, 1405 DCHECK_GE(in_flight_write_frame_size_,
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 base::StatsCounter abandoned_streams("spdy.abandoned_streams"); 1612 base::StatsCounter abandoned_streams("spdy.abandoned_streams");
1604 abandoned_streams.Increment(); 1613 abandoned_streams.Increment();
1605 if (it->second.stream->type() == SPDY_PUSH_STREAM && 1614 if (it->second.stream->type() == SPDY_PUSH_STREAM &&
1606 unclaimed_pushed_streams_.find(it->second.stream->url()) != 1615 unclaimed_pushed_streams_.find(it->second.stream->url()) !=
1607 unclaimed_pushed_streams_.end()) { 1616 unclaimed_pushed_streams_.end()) {
1608 base::StatsCounter abandoned_push_streams("spdy.abandoned_push_streams"); 1617 base::StatsCounter abandoned_push_streams("spdy.abandoned_push_streams");
1609 abandoned_push_streams.Increment(); 1618 abandoned_push_streams.Increment();
1610 } 1619 }
1611 } 1620 }
1612 1621
1613 int SpdySession::GetNewStreamId() { 1622 SpdyStreamId SpdySession::GetNewStreamId() {
1614 int id = stream_hi_water_mark_; 1623 CHECK_LE(stream_hi_water_mark_, kLastStreamId);
1624 SpdyStreamId id = stream_hi_water_mark_;
1615 stream_hi_water_mark_ += 2; 1625 stream_hi_water_mark_ += 2;
1616 if (stream_hi_water_mark_ > 0x7fff)
1617 stream_hi_water_mark_ = 1;
1618 return id; 1626 return id;
1619 } 1627 }
1620 1628
1621 void SpdySession::CloseSessionOnError(Error err, 1629 void SpdySession::CloseSessionOnError(Error err,
1622 const std::string& description) { 1630 const std::string& description) {
1623 // We may be called from anywhere, so we can't expect a particular 1631 // We may be called from anywhere, so we can't expect a particular
1624 // return value. 1632 // return value.
1625 ignore_result(DoCloseSession(err, description)); 1633 ignore_result(DoCloseSession(err, description));
1626 } 1634 }
1627 1635
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after
3050 if (!queue->empty()) { 3058 if (!queue->empty()) {
3051 SpdyStreamId stream_id = queue->front(); 3059 SpdyStreamId stream_id = queue->front();
3052 queue->pop_front(); 3060 queue->pop_front();
3053 return stream_id; 3061 return stream_id;
3054 } 3062 }
3055 } 3063 }
3056 return 0; 3064 return 0;
3057 } 3065 }
3058 3066
3059 } // namespace net 3067 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698