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
3 // found in the LICENSE file.
5 #include "net/quic/quic_session.h"
7 #include "base/stl_util.h"
8 #include "net/quic/crypto/proof_verifier.h"
9 #include "net/quic/quic_connection.h"
10 #include "net/quic/quic_flow_controller.h"
11 #include "net/quic/quic_headers_stream.h"
12 #include "net/ssl/ssl_info.h"
14 using base::StringPiece
;
26 (perspective() == Perspective::IS_SERVER ? "Server: " : " Client: ")
28 // We want to make sure we delete any closed streams in a safe manner.
29 // To avoid deleting a stream in mid-operation, we have a simple shim between
30 // us and the stream, so we can delete any streams when we return from
33 // We could just override the base methods, but this makes it easier to make
34 // sure we don't miss any.
35 class VisitorShim
: public QuicConnectionVisitorInterface
{
37 explicit VisitorShim(QuicSession
* session
) : session_(session
) {}
39 void OnStreamFrames(const vector
<QuicStreamFrame
>& frames
) override
{
40 session_
->OnStreamFrames(frames
);
41 session_
->PostProcessAfterData();
43 void OnRstStream(const QuicRstStreamFrame
& frame
) override
{
44 session_
->OnRstStream(frame
);
45 session_
->PostProcessAfterData();
48 void OnGoAway(const QuicGoAwayFrame
& frame
) override
{
49 session_
->OnGoAway(frame
);
50 session_
->PostProcessAfterData();
53 void OnWindowUpdateFrames(
54 const vector
<QuicWindowUpdateFrame
>& frames
) override
{
55 session_
->OnWindowUpdateFrames(frames
);
56 session_
->PostProcessAfterData();
59 void OnBlockedFrames(const vector
<QuicBlockedFrame
>& frames
) override
{
60 session_
->OnBlockedFrames(frames
);
61 session_
->PostProcessAfterData();
64 void OnCanWrite() override
{
65 session_
->OnCanWrite();
66 session_
->PostProcessAfterData();
69 void OnCongestionWindowChange(QuicTime now
) override
{
70 session_
->OnCongestionWindowChange(now
);
73 void OnSuccessfulVersionNegotiation(const QuicVersion
& version
) override
{
74 session_
->OnSuccessfulVersionNegotiation(version
);
77 void OnConnectionClosed(QuicErrorCode error
, bool from_peer
) override
{
78 session_
->OnConnectionClosed(error
, from_peer
);
79 // The session will go away, so don't bother with cleanup.
82 void OnWriteBlocked() override
{ session_
->OnWriteBlocked(); }
84 bool WillingAndAbleToWrite() const override
{
85 return session_
->WillingAndAbleToWrite();
88 bool HasPendingHandshake() const override
{
89 return session_
->HasPendingHandshake();
92 bool HasOpenDataStreams() const override
{
93 return session_
->HasOpenDataStreams();
97 QuicSession
* session_
;
100 QuicSession::QuicSession(QuicConnection
* connection
, const QuicConfig
& config
)
101 : connection_(connection
),
102 visitor_shim_(new VisitorShim(this)),
104 max_open_streams_(config_
.MaxStreamsPerConnection()),
105 next_stream_id_(perspective() == Perspective::IS_SERVER
? 2 : 5),
106 write_blocked_streams_(true),
107 largest_peer_created_stream_id_(0),
108 error_(QUIC_NO_ERROR
),
109 flow_controller_(new QuicFlowController(
113 kMinimumFlowControlSendWindow
,
114 config_
.GetInitialSessionFlowControlWindowToSend(),
115 config_
.GetInitialSessionFlowControlWindowToSend())),
116 goaway_received_(false),
118 has_pending_handshake_(false) {
121 void QuicSession::InitializeSession() {
122 connection_
->set_visitor(visitor_shim_
.get());
123 connection_
->SetFromConfig(config_
);
124 headers_stream_
.reset(new QuicHeadersStream(this));
127 QuicSession::~QuicSession() {
128 STLDeleteElements(&closed_streams_
);
129 STLDeleteValues(&stream_map_
);
132 locally_closed_streams_highest_offset_
.size() > max_open_streams_
)
133 << "Surprisingly high number of locally closed streams still waiting for "
134 "final byte offset: " << locally_closed_streams_highest_offset_
.size();
137 void QuicSession::OnStreamFrames(const vector
<QuicStreamFrame
>& frames
) {
138 for (size_t i
= 0; i
< frames
.size(); ++i
) {
139 // TODO(rch) deal with the error case of stream id 0.
140 const QuicStreamFrame
& frame
= frames
[i
];
141 QuicStreamId stream_id
= frame
.stream_id
;
142 ReliableQuicStream
* stream
= GetStream(stream_id
);
144 // The stream no longer exists, but we may still be interested in the
145 // final stream byte offset sent by the peer. A frame with a FIN can give
148 QuicStreamOffset final_byte_offset
=
149 frame
.offset
+ frame
.data
.TotalBufferSize();
150 UpdateFlowControlOnFinalReceivedByteOffset(stream_id
,
156 stream
->OnStreamFrame(frames
[i
]);
160 void QuicSession::OnStreamHeaders(QuicStreamId stream_id
,
161 StringPiece headers_data
) {
162 QuicDataStream
* stream
= GetDataStream(stream_id
);
164 // It's quite possible to receive headers after a stream has been reset.
167 stream
->OnStreamHeaders(headers_data
);
170 void QuicSession::OnStreamHeadersPriority(QuicStreamId stream_id
,
171 QuicPriority priority
) {
172 QuicDataStream
* stream
= GetDataStream(stream_id
);
174 // It's quite possible to receive headers after a stream has been reset.
177 stream
->OnStreamHeadersPriority(priority
);
180 void QuicSession::OnStreamHeadersComplete(QuicStreamId stream_id
,
183 QuicDataStream
* stream
= GetDataStream(stream_id
);
185 // It's quite possible to receive headers after a stream has been reset.
188 stream
->OnStreamHeadersComplete(fin
, frame_len
);
191 void QuicSession::OnRstStream(const QuicRstStreamFrame
& frame
) {
192 if (frame
.stream_id
== kCryptoStreamId
) {
193 connection()->SendConnectionCloseWithDetails(
194 QUIC_INVALID_STREAM_ID
,
195 "Attempt to reset the crypto stream");
198 if (frame
.stream_id
== kHeadersStreamId
) {
199 connection()->SendConnectionCloseWithDetails(
200 QUIC_INVALID_STREAM_ID
,
201 "Attempt to reset the headers stream");
205 QuicDataStream
* stream
= GetDataStream(frame
.stream_id
);
207 // The RST frame contains the final byte offset for the stream: we can now
208 // update the connection level flow controller if needed.
209 UpdateFlowControlOnFinalReceivedByteOffset(frame
.stream_id
,
211 return; // Errors are handled by GetStream.
214 stream
->OnStreamReset(frame
);
217 void QuicSession::OnGoAway(const QuicGoAwayFrame
& frame
) {
218 DCHECK(frame
.last_good_stream_id
< next_stream_id_
);
219 goaway_received_
= true;
222 void QuicSession::OnConnectionClosed(QuicErrorCode error
, bool from_peer
) {
223 DCHECK(!connection_
->connected());
224 if (error_
== QUIC_NO_ERROR
) {
228 while (!stream_map_
.empty()) {
229 DataStreamMap::iterator it
= stream_map_
.begin();
230 QuicStreamId id
= it
->first
;
231 it
->second
->OnConnectionClosed(error
, from_peer
);
232 // The stream should call CloseStream as part of OnConnectionClosed.
233 if (stream_map_
.find(id
) != stream_map_
.end()) {
234 LOG(DFATAL
) << ENDPOINT
235 << "Stream failed to close under OnConnectionClosed";
241 void QuicSession::OnSuccessfulVersionNegotiation(const QuicVersion
& version
) {
242 headers_stream_
->OnSuccessfulVersionNegotiation(version
);
245 void QuicSession::OnWindowUpdateFrames(
246 const vector
<QuicWindowUpdateFrame
>& frames
) {
247 bool connection_window_updated
= false;
248 for (size_t i
= 0; i
< frames
.size(); ++i
) {
249 // Stream may be closed by the time we receive a WINDOW_UPDATE, so we can't
250 // assume that it still exists.
251 QuicStreamId stream_id
= frames
[i
].stream_id
;
252 if (stream_id
== kConnectionLevelId
) {
253 // This is a window update that applies to the connection, rather than an
254 // individual stream.
256 << "Received connection level flow control window update with "
257 "byte offset: " << frames
[i
].byte_offset
;
258 if (flow_controller_
->UpdateSendWindowOffset(frames
[i
].byte_offset
)) {
259 connection_window_updated
= true;
264 ReliableQuicStream
* stream
= GetStream(stream_id
);
266 stream
->OnWindowUpdateFrame(frames
[i
]);
270 // Connection level flow control window has increased, so blocked streams can
272 if (connection_window_updated
) {
277 void QuicSession::OnBlockedFrames(const vector
<QuicBlockedFrame
>& frames
) {
278 for (size_t i
= 0; i
< frames
.size(); ++i
) {
279 // TODO(rjshade): Compare our flow control receive windows for specified
280 // streams: if we have a large window then maybe something
281 // had gone wrong with the flow control accounting.
282 DVLOG(1) << ENDPOINT
<< "Received BLOCKED frame with stream id: "
283 << frames
[i
].stream_id
;
287 void QuicSession::OnCanWrite() {
288 // We limit the number of writes to the number of pending streams. If more
289 // streams become pending, WillingAndAbleToWrite will be true, which will
290 // cause the connection to request resumption before yielding to other
292 size_t num_writes
= write_blocked_streams_
.NumBlockedStreams();
293 if (flow_controller_
->IsBlocked()) {
294 // If we are connection level flow control blocked, then only allow the
295 // crypto and headers streams to try writing as all other streams will be
298 if (write_blocked_streams_
.crypto_stream_blocked()) {
301 if (write_blocked_streams_
.headers_stream_blocked()) {
305 if (num_writes
== 0) {
309 QuicConnection::ScopedPacketBundler
ack_bundler(
310 connection_
.get(), QuicConnection::NO_ACK
);
311 for (size_t i
= 0; i
< num_writes
; ++i
) {
312 if (!(write_blocked_streams_
.HasWriteBlockedCryptoOrHeadersStream() ||
313 write_blocked_streams_
.HasWriteBlockedDataStreams())) {
314 // Writing one stream removed another!? Something's broken.
315 LOG(DFATAL
) << "WriteBlockedStream is missing";
316 connection_
->CloseConnection(QUIC_INTERNAL_ERROR
, false);
319 if (!connection_
->CanWriteStreamData()) {
322 QuicStreamId stream_id
= write_blocked_streams_
.PopFront();
323 if (stream_id
== kCryptoStreamId
) {
324 has_pending_handshake_
= false; // We just popped it.
326 ReliableQuicStream
* stream
= GetStream(stream_id
);
327 if (stream
!= nullptr && !stream
->flow_controller()->IsBlocked()) {
328 // If the stream can't write all bytes, it'll re-add itself to the blocked
330 stream
->OnCanWrite();
335 bool QuicSession::WillingAndAbleToWrite() const {
336 // If the crypto or headers streams are blocked, we want to schedule a write -
337 // they don't get blocked by connection level flow control. Otherwise only
338 // schedule a write if we are not flow control blocked at the connection
340 return write_blocked_streams_
.HasWriteBlockedCryptoOrHeadersStream() ||
341 (!flow_controller_
->IsBlocked() &&
342 write_blocked_streams_
.HasWriteBlockedDataStreams());
345 bool QuicSession::HasPendingHandshake() const {
346 return has_pending_handshake_
;
349 bool QuicSession::HasOpenDataStreams() const {
350 return GetNumOpenStreams() > 0;
353 QuicConsumedData
QuicSession::WritevData(
355 const IOVector
& data
,
356 QuicStreamOffset offset
,
358 FecProtection fec_protection
,
359 QuicAckNotifier::DelegateInterface
* ack_notifier_delegate
) {
360 return connection_
->SendStreamData(id
, data
, offset
, fin
, fec_protection
,
361 ack_notifier_delegate
);
364 size_t QuicSession::WriteHeaders(
366 const SpdyHeaderBlock
& headers
,
368 QuicPriority priority
,
369 QuicAckNotifier::DelegateInterface
* ack_notifier_delegate
) {
370 return headers_stream_
->WriteHeaders(id
, headers
, fin
, priority
,
371 ack_notifier_delegate
);
374 void QuicSession::SendRstStream(QuicStreamId id
,
375 QuicRstStreamErrorCode error
,
376 QuicStreamOffset bytes_written
) {
377 if (connection()->connected()) {
378 // Only send a RST_STREAM frame if still connected.
379 connection_
->SendRstStream(id
, error
, bytes_written
);
381 CloseStreamInner(id
, true);
384 void QuicSession::SendGoAway(QuicErrorCode error_code
, const string
& reason
) {
389 connection_
->SendGoAway(error_code
, largest_peer_created_stream_id_
, reason
);
392 void QuicSession::CloseStream(QuicStreamId stream_id
) {
393 CloseStreamInner(stream_id
, false);
396 void QuicSession::CloseStreamInner(QuicStreamId stream_id
,
397 bool locally_reset
) {
398 DVLOG(1) << ENDPOINT
<< "Closing stream " << stream_id
;
400 DataStreamMap::iterator it
= stream_map_
.find(stream_id
);
401 if (it
== stream_map_
.end()) {
402 DVLOG(1) << ENDPOINT
<< "Stream is already closed: " << stream_id
;
405 QuicDataStream
* stream
= it
->second
;
407 // Tell the stream that a RST has been sent.
409 stream
->set_rst_sent(true);
412 closed_streams_
.push_back(it
->second
);
414 // If we haven't received a FIN or RST for this stream, we need to keep track
415 // of the how many bytes the stream's flow controller believes it has
416 // received, for accurate connection level flow control accounting.
417 if (!stream
->HasFinalReceivedByteOffset()) {
418 locally_closed_streams_highest_offset_
[stream_id
] =
419 stream
->flow_controller()->highest_received_byte_offset();
422 stream_map_
.erase(it
);
424 // Decrease the number of streams being emulated when a new one is opened.
425 connection_
->SetNumOpenStreams(stream_map_
.size());
428 void QuicSession::UpdateFlowControlOnFinalReceivedByteOffset(
429 QuicStreamId stream_id
, QuicStreamOffset final_byte_offset
) {
430 map
<QuicStreamId
, QuicStreamOffset
>::iterator it
=
431 locally_closed_streams_highest_offset_
.find(stream_id
);
432 if (it
== locally_closed_streams_highest_offset_
.end()) {
436 DVLOG(1) << ENDPOINT
<< "Received final byte offset " << final_byte_offset
437 << " for stream " << stream_id
;
438 QuicByteCount offset_diff
= final_byte_offset
- it
->second
;
439 if (flow_controller_
->UpdateHighestReceivedOffset(
440 flow_controller_
->highest_received_byte_offset() + offset_diff
)) {
441 // If the final offset violates flow control, close the connection now.
442 if (flow_controller_
->FlowControlViolation()) {
443 connection_
->SendConnectionClose(
444 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA
);
449 flow_controller_
->AddBytesConsumed(offset_diff
);
450 locally_closed_streams_highest_offset_
.erase(it
);
453 bool QuicSession::IsEncryptionEstablished() {
454 return GetCryptoStream()->encryption_established();
457 bool QuicSession::IsCryptoHandshakeConfirmed() {
458 return GetCryptoStream()->handshake_confirmed();
461 void QuicSession::OnConfigNegotiated() {
462 connection_
->SetFromConfig(config_
);
464 uint32 max_streams
= config_
.MaxStreamsPerConnection();
465 if (perspective() == Perspective::IS_SERVER
) {
466 // A server should accept a small number of additional streams beyond the
467 // limit sent to the client. This helps avoid early connection termination
468 // when FIN/RSTs for old streams are lost or arrive out of order.
469 // Use a minimum number of additional streams, or a percentage increase,
470 // whichever is larger.
472 max(max_streams
+ kMaxStreamsMinimumIncrement
,
473 static_cast<uint32
>(max_streams
* kMaxStreamsMultiplier
));
475 set_max_open_streams(max_streams
);
477 if (config_
.HasReceivedInitialStreamFlowControlWindowBytes()) {
478 // Streams which were created before the SHLO was received (0-RTT
479 // requests) are now informed of the peer's initial flow control window.
480 OnNewStreamFlowControlWindow(
481 config_
.ReceivedInitialStreamFlowControlWindowBytes());
483 if (config_
.HasReceivedInitialSessionFlowControlWindowBytes()) {
484 OnNewSessionFlowControlWindow(
485 config_
.ReceivedInitialSessionFlowControlWindowBytes());
489 void QuicSession::OnNewStreamFlowControlWindow(QuicStreamOffset new_window
) {
490 if (new_window
< kMinimumFlowControlSendWindow
) {
491 LOG(ERROR
) << "Peer sent us an invalid stream flow control send window: "
493 << ", below default: " << kMinimumFlowControlSendWindow
;
494 if (connection_
->connected()) {
495 connection_
->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW
);
500 // Inform all existing streams about the new window.
501 GetCryptoStream()->UpdateSendWindowOffset(new_window
);
502 headers_stream_
->UpdateSendWindowOffset(new_window
);
503 for (DataStreamMap::iterator it
= stream_map_
.begin();
504 it
!= stream_map_
.end(); ++it
) {
505 it
->second
->UpdateSendWindowOffset(new_window
);
509 void QuicSession::OnNewSessionFlowControlWindow(QuicStreamOffset new_window
) {
510 if (new_window
< kMinimumFlowControlSendWindow
) {
511 LOG(ERROR
) << "Peer sent us an invalid session flow control send window: "
513 << ", below default: " << kMinimumFlowControlSendWindow
;
514 if (connection_
->connected()) {
515 connection_
->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW
);
520 flow_controller_
->UpdateSendWindowOffset(new_window
);
523 void QuicSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event
) {
525 // TODO(satyamshekhar): Move the logic of setting the encrypter/decrypter
526 // to QuicSession since it is the glue.
527 case ENCRYPTION_FIRST_ESTABLISHED
:
530 case ENCRYPTION_REESTABLISHED
:
531 // Retransmit originally packets that were sent, since they can't be
532 // decrypted by the peer.
533 connection_
->RetransmitUnackedPackets(ALL_INITIAL_RETRANSMISSION
);
536 case HANDSHAKE_CONFIRMED
:
537 LOG_IF(DFATAL
, !config_
.negotiated()) << ENDPOINT
538 << "Handshake confirmed without parameter negotiation.";
539 // Discard originally encrypted packets, since they can't be decrypted by
541 connection_
->NeuterUnencryptedPackets();
545 LOG(ERROR
) << ENDPOINT
<< "Got unknown handshake event: " << event
;
549 void QuicSession::OnCryptoHandshakeMessageSent(
550 const CryptoHandshakeMessage
& message
) {
553 void QuicSession::OnCryptoHandshakeMessageReceived(
554 const CryptoHandshakeMessage
& message
) {
557 QuicConfig
* QuicSession::config() {
561 void QuicSession::ActivateStream(QuicDataStream
* stream
) {
562 DVLOG(1) << ENDPOINT
<< "num_streams: " << stream_map_
.size()
563 << ". activating " << stream
->id();
564 DCHECK_EQ(stream_map_
.count(stream
->id()), 0u);
565 stream_map_
[stream
->id()] = stream
;
566 // Increase the number of streams being emulated when a new one is opened.
567 connection_
->SetNumOpenStreams(stream_map_
.size());
570 QuicStreamId
QuicSession::GetNextStreamId() {
571 QuicStreamId id
= next_stream_id_
;
572 next_stream_id_
+= 2;
576 ReliableQuicStream
* QuicSession::GetStream(const QuicStreamId stream_id
) {
577 if (stream_id
== kCryptoStreamId
) {
578 return GetCryptoStream();
580 if (stream_id
== kHeadersStreamId
) {
581 return headers_stream_
.get();
583 return GetDataStream(stream_id
);
586 QuicDataStream
* QuicSession::GetDataStream(const QuicStreamId stream_id
) {
587 if (stream_id
== kCryptoStreamId
) {
588 DLOG(FATAL
) << "Attempt to call GetDataStream with the crypto stream id";
591 if (stream_id
== kHeadersStreamId
) {
592 DLOG(FATAL
) << "Attempt to call GetDataStream with the headers stream id";
596 DataStreamMap::iterator it
= stream_map_
.find(stream_id
);
597 if (it
!= stream_map_
.end()) {
601 if (IsClosedStream(stream_id
)) {
605 if (stream_id
% 2 == next_stream_id_
% 2) {
606 // We've received a frame for a locally-created stream that is not
607 // currently active. This is an error.
608 if (connection()->connected()) {
609 connection()->SendConnectionClose(QUIC_PACKET_FOR_NONEXISTENT_STREAM
);
614 return GetIncomingDataStream(stream_id
);
617 QuicDataStream
* QuicSession::GetIncomingDataStream(QuicStreamId stream_id
) {
618 if (IsClosedStream(stream_id
)) {
622 implicitly_created_streams_
.erase(stream_id
);
623 if (stream_id
> largest_peer_created_stream_id_
) {
624 if (stream_id
- largest_peer_created_stream_id_
> kMaxStreamIdDelta
) {
625 // We may already have sent a connection close due to multiple reset
626 // streams in the same packet.
627 if (connection()->connected()) {
628 LOG(ERROR
) << "Trying to get stream: " << stream_id
629 << ", largest peer created stream: "
630 << largest_peer_created_stream_id_
631 << ", max delta: " << kMaxStreamIdDelta
;
632 connection()->SendConnectionClose(QUIC_INVALID_STREAM_ID
);
636 if (largest_peer_created_stream_id_
== 0) {
637 if (perspective() == Perspective::IS_SERVER
) {
638 largest_peer_created_stream_id_
= 3;
640 largest_peer_created_stream_id_
= 1;
643 for (QuicStreamId id
= largest_peer_created_stream_id_
+ 2;
646 implicitly_created_streams_
.insert(id
);
648 largest_peer_created_stream_id_
= stream_id
;
650 QuicDataStream
* stream
= CreateIncomingDataStream(stream_id
);
651 if (stream
== nullptr) {
654 ActivateStream(stream
);
658 void QuicSession::set_max_open_streams(size_t max_open_streams
) {
659 DVLOG(1) << "Setting max_open_streams_ to " << max_open_streams
;
660 max_open_streams_
= max_open_streams
;
663 bool QuicSession::IsClosedStream(QuicStreamId id
) {
665 if (id
== kCryptoStreamId
) {
668 if (id
== kHeadersStreamId
) {
671 if (ContainsKey(stream_map_
, id
)) {
675 if (id
% 2 == next_stream_id_
% 2) {
676 // Locally created streams are strictly in-order. If the id is in the
677 // range of created streams and it's not active, it must have been closed.
678 return id
< next_stream_id_
;
680 // For peer created streams, we also need to consider implicitly created
682 return id
<= largest_peer_created_stream_id_
&&
683 !ContainsKey(implicitly_created_streams_
, id
);
686 size_t QuicSession::GetNumOpenStreams() const {
687 return stream_map_
.size() + implicitly_created_streams_
.size();
690 void QuicSession::MarkWriteBlocked(QuicStreamId id
, QuicPriority priority
) {
692 ReliableQuicStream
* stream
= GetStream(id
);
693 if (stream
!= nullptr) {
694 LOG_IF(DFATAL
, priority
!= stream
->EffectivePriority())
695 << ENDPOINT
<< "Stream " << id
696 << "Priorities do not match. Got: " << priority
697 << " Expected: " << stream
->EffectivePriority();
699 LOG(DFATAL
) << "Marking unknown stream " << id
<< " blocked.";
703 if (id
== kCryptoStreamId
) {
704 DCHECK(!has_pending_handshake_
);
705 has_pending_handshake_
= true;
706 // TODO(jar): Be sure to use the highest priority for the crypto stream,
707 // perhaps by adding a "special" priority for it that is higher than
709 priority
= kHighestPriority
;
711 write_blocked_streams_
.PushBack(id
, priority
);
714 bool QuicSession::HasDataToWrite() const {
715 return write_blocked_streams_
.HasWriteBlockedCryptoOrHeadersStream() ||
716 write_blocked_streams_
.HasWriteBlockedDataStreams() ||
717 connection_
->HasQueuedData();
720 void QuicSession::PostProcessAfterData() {
721 STLDeleteElements(&closed_streams_
);
723 if (connection()->connected() &&
724 locally_closed_streams_highest_offset_
.size() > max_open_streams_
) {
725 // A buggy client may fail to send FIN/RSTs. Don't tolerate this.
726 connection_
->SendConnectionClose(QUIC_TOO_MANY_UNFINISHED_STREAMS
);
730 bool QuicSession::IsConnectionFlowControlBlocked() const {
731 return flow_controller_
->IsBlocked();
734 bool QuicSession::IsStreamFlowControlBlocked() {
735 if (headers_stream_
->flow_controller()->IsBlocked() ||
736 GetCryptoStream()->flow_controller()->IsBlocked()) {
739 for (DataStreamMap::iterator it
= stream_map_
.begin();
740 it
!= stream_map_
.end(); ++it
) {
741 if (it
->second
->flow_controller()->IsBlocked()) {