| Index: net/quic/quic_session.cc
|
| diff --git a/net/quic/quic_session.cc b/net/quic/quic_session.cc
|
| index 6147224c2fc0e5789f0aa0514ff1270f8c468782..b84eb6aaa57e3fdd1df6f86affd89aaa37de0f20 100644
|
| --- a/net/quic/quic_session.cc
|
| +++ b/net/quic/quic_session.cc
|
| @@ -18,9 +18,6 @@ using std::vector;
|
|
|
| namespace net {
|
|
|
| -const size_t kMaxPrematurelyClosedStreamsTracked = 20;
|
| -const size_t kMaxZombieStreams = 20;
|
| -
|
| #define ENDPOINT (is_server() ? "Server: " : " Client: ")
|
|
|
| // We want to make sure we delete any closed streams in a safe manner.
|
| @@ -112,14 +109,12 @@ QuicSession::QuicSession(QuicConnection* connection,
|
| connection_->SetOverallConnectionTimeout(
|
| config_.max_time_before_crypto_handshake());
|
| }
|
| - if (connection_->version() > QUIC_VERSION_12) {
|
| - headers_stream_.reset(new QuicHeadersStream(this));
|
| - if (!is_server()) {
|
| - // For version above QUIC v12, the headers stream is stream 3, so the
|
| - // next available local stream ID should be 5.
|
| - DCHECK_EQ(kHeadersStreamId, next_stream_id_);
|
| - next_stream_id_ += 2;
|
| - }
|
| + headers_stream_.reset(new QuicHeadersStream(this));
|
| + if (!is_server()) {
|
| + // For version above QUIC v12, the headers stream is stream 3, so the
|
| + // next available local stream ID should be 5.
|
| + DCHECK_EQ(kHeadersStreamId, next_stream_id_);
|
| + next_stream_id_ += 2;
|
| }
|
| }
|
|
|
| @@ -132,15 +127,6 @@ bool QuicSession::OnStreamFrames(const vector<QuicStreamFrame>& frames) {
|
| for (size_t i = 0; i < frames.size(); ++i) {
|
| // TODO(rch) deal with the error case of stream id 0
|
| if (IsClosedStream(frames[i].stream_id)) {
|
| - // If we get additional frames for a stream where we didn't process
|
| - // headers, it's highly likely our compression context will end up
|
| - // permanently out of sync with the peer's, so we give up and close the
|
| - // connection.
|
| - if (ContainsKey(prematurely_closed_streams_, frames[i].stream_id)) {
|
| - connection()->SendConnectionClose(
|
| - QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED);
|
| - return false;
|
| - }
|
| continue;
|
| }
|
|
|
| @@ -159,31 +145,8 @@ bool QuicSession::OnStreamFrames(const vector<QuicStreamFrame>& frames) {
|
| continue;
|
| }
|
| stream->OnStreamFrame(frames[i]);
|
| -
|
| - // If the stream is a data stream had been prematurely closed, and the
|
| - // headers are now decompressed, then we are finally finished
|
| - // with this stream.
|
| - if (ContainsKey(zombie_streams_, stream_id) &&
|
| - static_cast<QuicDataStream*>(stream)->headers_decompressed()) {
|
| - CloseZombieStream(stream_id);
|
| - }
|
| }
|
|
|
| - while (!decompression_blocked_streams_.empty()) {
|
| - QuicHeaderId header_id = decompression_blocked_streams_.begin()->first;
|
| - if (header_id != decompressor_.current_header_id()) {
|
| - break;
|
| - }
|
| - QuicStreamId stream_id = decompression_blocked_streams_.begin()->second;
|
| - decompression_blocked_streams_.erase(header_id);
|
| - QuicDataStream* stream = GetDataStream(stream_id);
|
| - if (!stream) {
|
| - connection()->SendConnectionClose(
|
| - QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED);
|
| - return false;
|
| - }
|
| - stream->OnDecompressorAvailable();
|
| - }
|
| return true;
|
| }
|
|
|
| @@ -225,8 +188,7 @@ void QuicSession::OnRstStream(const QuicRstStreamFrame& frame) {
|
| "Attempt to reset the crypto stream");
|
| return;
|
| }
|
| - if (frame.stream_id == kHeadersStreamId &&
|
| - connection()->version() > QUIC_VERSION_12) {
|
| + if (frame.stream_id == kHeadersStreamId) {
|
| connection()->SendConnectionCloseWithDetails(
|
| QUIC_INVALID_STREAM_ID,
|
| "Attempt to reset the headers stream");
|
| @@ -236,23 +198,7 @@ void QuicSession::OnRstStream(const QuicRstStreamFrame& frame) {
|
| if (!stream) {
|
| return; // Errors are handled by GetStream.
|
| }
|
| - // TODO(rjshade): Adjust flow control windows based on frame.byte_offset.
|
| - if (ContainsKey(zombie_streams_, stream->id())) {
|
| - // If this was a zombie stream then we close it out now.
|
| - CloseZombieStream(stream->id());
|
| - // However, since the headers still have not been decompressed, we want to
|
| - // mark it a prematurely closed so that if we ever receive frames
|
| - // for this stream we can close the connection.
|
| - DCHECK(!stream->headers_decompressed());
|
| - AddPrematurelyClosedStream(frame.stream_id);
|
| - return;
|
| - }
|
| - if (connection()->version() <= QUIC_VERSION_12) {
|
| - if (stream->stream_bytes_read() > 0 && !stream->headers_decompressed()) {
|
| - connection()->SendConnectionClose(
|
| - QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED);
|
| - }
|
| - }
|
| +
|
| stream->OnStreamReset(frame);
|
| }
|
|
|
| @@ -363,10 +309,6 @@ QuicConsumedData QuicSession::WritevData(
|
| size_t QuicSession::WriteHeaders(QuicStreamId id,
|
| const SpdyHeaderBlock& headers,
|
| bool fin) {
|
| - DCHECK_LT(QUIC_VERSION_12, connection()->version());
|
| - if (connection()->version() <= QUIC_VERSION_12) {
|
| - return 0;
|
| - }
|
| return headers_stream_->WriteHeaders(id, headers, fin);
|
| }
|
|
|
| @@ -402,69 +344,11 @@ void QuicSession::CloseStreamInner(QuicStreamId stream_id,
|
| stream->set_rst_sent(true);
|
| }
|
|
|
| - if (connection_->version() <= QUIC_VERSION_12 &&
|
| - connection_->connected() && !stream->headers_decompressed()) {
|
| - // If the stream is being closed locally (for example a client cancelling
|
| - // a request before receiving the response) then we need to make sure that
|
| - // we keep the stream alive long enough to process any response or
|
| - // RST_STREAM frames.
|
| - if (locally_reset && !is_server()) {
|
| - AddZombieStream(stream_id);
|
| - return;
|
| - }
|
| -
|
| - // This stream has been closed before the headers were decompressed.
|
| - // This might cause problems with head of line blocking of headers.
|
| - // If the peer sent headers which were lost but we now close the stream
|
| - // we will never be able to decompress headers for other streams.
|
| - // To deal with this, we keep track of streams which have been closed
|
| - // prematurely. If we ever receive data frames for this steam, then we
|
| - // know there actually has been a problem and we close the connection.
|
| - AddPrematurelyClosedStream(stream->id());
|
| - }
|
| closed_streams_.push_back(it->second);
|
| - if (ContainsKey(zombie_streams_, stream->id())) {
|
| - zombie_streams_.erase(stream->id());
|
| - }
|
| stream_map_.erase(it);
|
| stream->OnClose();
|
| }
|
|
|
| -void QuicSession::AddZombieStream(QuicStreamId stream_id) {
|
| - if (zombie_streams_.size() == kMaxZombieStreams) {
|
| - QuicStreamId oldest_zombie_stream_id = zombie_streams_.begin()->first;
|
| - CloseZombieStream(oldest_zombie_stream_id);
|
| - // However, since the headers still have not been decompressed, we want to
|
| - // mark it a prematurely closed so that if we ever receive frames
|
| - // for this stream we can close the connection.
|
| - AddPrematurelyClosedStream(oldest_zombie_stream_id);
|
| - }
|
| - zombie_streams_.insert(make_pair(stream_id, true));
|
| -}
|
| -
|
| -void QuicSession::CloseZombieStream(QuicStreamId stream_id) {
|
| - DCHECK(ContainsKey(zombie_streams_, stream_id));
|
| - zombie_streams_.erase(stream_id);
|
| - QuicDataStream* stream = GetDataStream(stream_id);
|
| - if (!stream) {
|
| - return;
|
| - }
|
| - stream_map_.erase(stream_id);
|
| - stream->OnClose();
|
| - closed_streams_.push_back(stream);
|
| -}
|
| -
|
| -void QuicSession::AddPrematurelyClosedStream(QuicStreamId stream_id) {
|
| - if (connection()->version() > QUIC_VERSION_12) {
|
| - return;
|
| - }
|
| - if (prematurely_closed_streams_.size() ==
|
| - kMaxPrematurelyClosedStreamsTracked) {
|
| - prematurely_closed_streams_.erase(prematurely_closed_streams_.begin());
|
| - }
|
| - prematurely_closed_streams_.insert(make_pair(stream_id, true));
|
| -}
|
| -
|
| bool QuicSession::IsEncryptionEstablished() {
|
| return GetCryptoStream()->encryption_established();
|
| }
|
| @@ -531,8 +415,7 @@ ReliableQuicStream* QuicSession::GetStream(const QuicStreamId stream_id) {
|
| if (stream_id == kCryptoStreamId) {
|
| return GetCryptoStream();
|
| }
|
| - if (stream_id == kHeadersStreamId &&
|
| - connection_->version() > QUIC_VERSION_12) {
|
| + if (stream_id == kHeadersStreamId) {
|
| return headers_stream_.get();
|
| }
|
| return GetDataStream(stream_id);
|
| @@ -543,8 +426,7 @@ QuicDataStream* QuicSession::GetDataStream(const QuicStreamId stream_id) {
|
| DLOG(FATAL) << "Attempt to call GetDataStream with the crypto stream id";
|
| return NULL;
|
| }
|
| - if (stream_id == kHeadersStreamId &&
|
| - connection_->version() > QUIC_VERSION_12) {
|
| + if (stream_id == kHeadersStreamId) {
|
| DLOG(FATAL) << "Attempt to call GetDataStream with the headers stream id";
|
| return NULL;
|
| }
|
| @@ -589,7 +471,7 @@ QuicDataStream* QuicSession::GetIncomingDataStream(QuicStreamId stream_id) {
|
| return NULL;
|
| }
|
| if (largest_peer_created_stream_id_ == 0) {
|
| - if (is_server() && connection()->version() > QUIC_VERSION_12) {
|
| + if (is_server()) {
|
| largest_peer_created_stream_id_= 3;
|
| } else {
|
| largest_peer_created_stream_id_= 1;
|
| @@ -615,13 +497,8 @@ bool QuicSession::IsClosedStream(QuicStreamId id) {
|
| if (id == kCryptoStreamId) {
|
| return false;
|
| }
|
| - if (connection()->version() > QUIC_VERSION_12) {
|
| - if (id == kHeadersStreamId) {
|
| - return false;
|
| - }
|
| - }
|
| - if (ContainsKey(zombie_streams_, id)) {
|
| - return true;
|
| + if (id == kHeadersStreamId) {
|
| + return false;
|
| }
|
| if (ContainsKey(stream_map_, id)) {
|
| // Stream is active
|
| @@ -639,8 +516,7 @@ bool QuicSession::IsClosedStream(QuicStreamId id) {
|
| }
|
|
|
| size_t QuicSession::GetNumOpenStreams() const {
|
| - return stream_map_.size() + implicitly_created_streams_.size() -
|
| - zombie_streams_.size();
|
| + return stream_map_.size() + implicitly_created_streams_.size();
|
| }
|
|
|
| void QuicSession::MarkWriteBlocked(QuicStreamId id, QuicPriority priority) {
|
| @@ -663,7 +539,7 @@ void QuicSession::MarkWriteBlocked(QuicStreamId id, QuicPriority priority) {
|
| // kHighestPriority.
|
| priority = kHighestPriority;
|
| }
|
| - write_blocked_streams_.PushBack(id, priority, connection()->version());
|
| + write_blocked_streams_.PushBack(id, priority);
|
| }
|
|
|
| bool QuicSession::HasDataToWrite() const {
|
| @@ -671,12 +547,6 @@ bool QuicSession::HasDataToWrite() const {
|
| connection_->HasQueuedData();
|
| }
|
|
|
| -void QuicSession::MarkDecompressionBlocked(QuicHeaderId header_id,
|
| - QuicStreamId stream_id) {
|
| - DCHECK_GE(QUIC_VERSION_12, connection()->version());
|
| - decompression_blocked_streams_[header_id] = stream_id;
|
| -}
|
| -
|
| bool QuicSession::GetSSLInfo(SSLInfo* ssl_info) {
|
| NOTIMPLEMENTED();
|
| return false;
|
|
|