| OLD | NEW |
| 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/quic/core/quic_session.h" | 5 #include "net/quic/core/quic_session.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "net/quic/core/quic_connection.h" | 10 #include "net/quic/core/quic_connection.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 max_open_incoming_streams_) | 65 max_open_incoming_streams_) |
| 66 << "Surprisingly high number of locally closed peer initiated streams" | 66 << "Surprisingly high number of locally closed peer initiated streams" |
| 67 "still waiting for final byte offset: " | 67 "still waiting for final byte offset: " |
| 68 << num_locally_closed_incoming_streams_highest_offset(); | 68 << num_locally_closed_incoming_streams_highest_offset(); |
| 69 QUIC_LOG_IF(WARNING, GetNumLocallyClosedOutgoingStreamsHighestOffset() > | 69 QUIC_LOG_IF(WARNING, GetNumLocallyClosedOutgoingStreamsHighestOffset() > |
| 70 max_open_outgoing_streams_) | 70 max_open_outgoing_streams_) |
| 71 << "Surprisingly high number of locally closed self initiated streams" | 71 << "Surprisingly high number of locally closed self initiated streams" |
| 72 "still waiting for final byte offset: " | 72 "still waiting for final byte offset: " |
| 73 << GetNumLocallyClosedOutgoingStreamsHighestOffset(); | 73 << GetNumLocallyClosedOutgoingStreamsHighestOffset(); |
| 74 QUIC_LOG_IF(WARNING, !zombie_streams_.empty()) << "Still have zombie streams"; | 74 QUIC_LOG_IF(WARNING, !zombie_streams_.empty()) << "Still have zombie streams"; |
| 75 for (const auto& kv : dynamic_stream_map_) { | |
| 76 QUIC_LOG_IF(WARNING, !kv.second->is_deletable()) | |
| 77 << "Still have non-deletable stream"; | |
| 78 } | |
| 79 } | 75 } |
| 80 | 76 |
| 81 void QuicSession::OnStreamFrame(const QuicStreamFrame& frame) { | 77 void QuicSession::OnStreamFrame(const QuicStreamFrame& frame) { |
| 82 // TODO(rch) deal with the error case of stream id 0. | 78 // TODO(rch) deal with the error case of stream id 0. |
| 83 QuicStreamId stream_id = frame.stream_id; | 79 QuicStreamId stream_id = frame.stream_id; |
| 84 QuicStream* stream = GetOrCreateStream(stream_id); | 80 QuicStream* stream = GetOrCreateStream(stream_id); |
| 85 if (!stream) { | 81 if (!stream) { |
| 86 // The stream no longer exists, but we may still be interested in the | 82 // The stream no longer exists, but we may still be interested in the |
| 87 // final stream byte offset sent by the peer. A frame with a FIN can give | 83 // final stream byte offset sent by the peer. A frame with a FIN can give |
| 88 // us this offset. | 84 // us this offset. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // The stream should call CloseStream as part of OnConnectionClosed. | 131 // The stream should call CloseStream as part of OnConnectionClosed. |
| 136 if (dynamic_stream_map_.find(id) != dynamic_stream_map_.end()) { | 132 if (dynamic_stream_map_.find(id) != dynamic_stream_map_.end()) { |
| 137 QUIC_BUG << ENDPOINT << "Stream failed to close under OnConnectionClosed"; | 133 QUIC_BUG << ENDPOINT << "Stream failed to close under OnConnectionClosed"; |
| 138 CloseStream(id); | 134 CloseStream(id); |
| 139 } | 135 } |
| 140 } | 136 } |
| 141 | 137 |
| 142 // Cleanup zombie stream map on connection close. | 138 // Cleanup zombie stream map on connection close. |
| 143 while (!zombie_streams_.empty()) { | 139 while (!zombie_streams_.empty()) { |
| 144 ZombieStreamMap::iterator it = zombie_streams_.begin(); | 140 ZombieStreamMap::iterator it = zombie_streams_.begin(); |
| 145 // Do not call OnConnectionClose as this may trigger unexpected operations | 141 closed_streams_.push_back(std::move(it->second)); |
| 146 // in subclass of QuicStream. | 142 zombie_streams_.erase(it); |
| 147 it->second->SetIsDeletable(true); | |
| 148 } | 143 } |
| 149 | 144 |
| 150 if (visitor_) { | 145 if (visitor_) { |
| 151 visitor_->OnConnectionClosed(connection_->connection_id(), error, | 146 visitor_->OnConnectionClosed(connection_->connection_id(), error, |
| 152 error_details); | 147 error_details); |
| 153 } | 148 } |
| 154 } | 149 } |
| 155 | 150 |
| 156 void QuicSession::OnWriteBlocked() { | 151 void QuicSession::OnWriteBlocked() { |
| 157 if (visitor_) { | 152 if (visitor_) { |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 QUIC_DLOG(INFO) << ENDPOINT << "Stream is already closed: " << stream_id; | 375 QUIC_DLOG(INFO) << ENDPOINT << "Stream is already closed: " << stream_id; |
| 381 return; | 376 return; |
| 382 } | 377 } |
| 383 QuicStream* stream = it->second.get(); | 378 QuicStream* stream = it->second.get(); |
| 384 | 379 |
| 385 // Tell the stream that a RST has been sent. | 380 // Tell the stream that a RST has been sent. |
| 386 if (locally_reset) { | 381 if (locally_reset) { |
| 387 stream->set_rst_sent(true); | 382 stream->set_rst_sent(true); |
| 388 } | 383 } |
| 389 | 384 |
| 390 if (stream->is_deletable()) { | 385 if (stream->IsWaitingForAcks()) { |
| 386 zombie_streams_[stream->id()] = std::move(it->second); |
| 387 } else { |
| 391 closed_streams_.push_back(std::move(it->second)); | 388 closed_streams_.push_back(std::move(it->second)); |
| 392 } else { | |
| 393 zombie_streams_[stream->id()] = std::move(it->second); | |
| 394 } | 389 } |
| 395 | 390 |
| 396 // If we haven't received a FIN or RST for this stream, we need to keep track | 391 // If we haven't received a FIN or RST for this stream, we need to keep track |
| 397 // of the how many bytes the stream's flow controller believes it has | 392 // of the how many bytes the stream's flow controller believes it has |
| 398 // received, for accurate connection level flow control accounting. | 393 // received, for accurate connection level flow control accounting. |
| 399 if (!stream->HasFinalReceivedByteOffset()) { | 394 if (!stream->HasFinalReceivedByteOffset()) { |
| 400 InsertLocallyClosedStreamsHighestOffset( | 395 InsertLocallyClosedStreamsHighestOffset( |
| 401 stream_id, stream->flow_controller()->highest_received_byte_offset()); | 396 stream_id, stream->flow_controller()->highest_received_byte_offset()); |
| 402 } | 397 } |
| 403 | 398 |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 return CreateAndActivateStream(GetNextOutgoingStreamId()); | 954 return CreateAndActivateStream(GetNextOutgoingStreamId()); |
| 960 } | 955 } |
| 961 | 956 |
| 962 QuicStream* QuicSession::CreateAndActivateStream(QuicStreamId id) { | 957 QuicStream* QuicSession::CreateAndActivateStream(QuicStreamId id) { |
| 963 std::unique_ptr<QuicStream> stream = CreateStream(id); | 958 std::unique_ptr<QuicStream> stream = CreateStream(id); |
| 964 QuicStream* stream_ptr = stream.get(); | 959 QuicStream* stream_ptr = stream.get(); |
| 965 ActivateStream(std::move(stream)); | 960 ActivateStream(std::move(stream)); |
| 966 return stream_ptr; | 961 return stream_ptr; |
| 967 } | 962 } |
| 968 | 963 |
| 969 void QuicSession::MarkStreamDeletable(QuicStreamId id) { | 964 void QuicSession::OnStreamDoneWaitingForAcks(QuicStreamId id) { |
| 970 auto it = zombie_streams_.find(id); | 965 auto it = zombie_streams_.find(id); |
| 971 if (it == zombie_streams_.end()) { | 966 if (it == zombie_streams_.end()) { |
| 972 return; | 967 return; |
| 973 } | 968 } |
| 974 | 969 |
| 975 closed_streams_.push_back(std::move(it->second)); | 970 closed_streams_.push_back(std::move(it->second)); |
| 976 zombie_streams_.erase(it); | 971 zombie_streams_.erase(it); |
| 977 } | 972 } |
| 978 | 973 |
| 979 QuicStream* QuicSession::GetStream(QuicStreamId id) const { | 974 QuicStream* QuicSession::GetStream(QuicStreamId id) const { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1001 } | 996 } |
| 1002 | 997 |
| 1003 void QuicSession::OnStreamFrameRetransmitted(const QuicStreamFrame& frame) { | 998 void QuicSession::OnStreamFrameRetransmitted(const QuicStreamFrame& frame) { |
| 1004 QuicStream* stream = GetStream(frame.stream_id); | 999 QuicStream* stream = GetStream(frame.stream_id); |
| 1005 if (stream != nullptr) { | 1000 if (stream != nullptr) { |
| 1006 stream->OnStreamFrameRetransmitted(frame); | 1001 stream->OnStreamFrameRetransmitted(frame); |
| 1007 } | 1002 } |
| 1008 } | 1003 } |
| 1009 | 1004 |
| 1010 } // namespace net | 1005 } // namespace net |
| OLD | NEW |