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/quic_session.h" | 5 #include "net/quic/quic_session.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #ifdef TEMP_INSTRUMENTATION_473893 | 8 #ifdef TEMP_INSTRUMENTATION_473893 |
9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
10 #endif | 10 #endif |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 return GetIncomingDynamicStream(stream_id); | 597 return GetIncomingDynamicStream(stream_id); |
598 } | 598 } |
599 | 599 |
600 ReliableQuicStream* QuicSession::GetIncomingDynamicStream( | 600 ReliableQuicStream* QuicSession::GetIncomingDynamicStream( |
601 QuicStreamId stream_id) { | 601 QuicStreamId stream_id) { |
602 if (IsClosedStream(stream_id)) { | 602 if (IsClosedStream(stream_id)) { |
603 return nullptr; | 603 return nullptr; |
604 } | 604 } |
605 implicitly_created_streams_.erase(stream_id); | 605 implicitly_created_streams_.erase(stream_id); |
606 if (stream_id > largest_peer_created_stream_id_) { | 606 if (stream_id > largest_peer_created_stream_id_) { |
607 if (FLAGS_exact_stream_id_delta) { | 607 // Check if the number of streams that will be created (including implicitly |
608 // Check if the number of streams that will be created (including | 608 // open streams) would cause the number of open streams to exceed the limit. |
609 // implicitly open streams) would cause the number of open streams to | 609 // Note that the peer can create only alternately-numbered streams. |
610 // exceed the limit. Note that the peer can create only | 610 if ((stream_id - largest_peer_created_stream_id_) / 2 + |
611 // alternately-numbered streams. | 611 GetNumOpenStreams() > |
612 if ((stream_id - largest_peer_created_stream_id_) / 2 + | 612 get_max_open_streams()) { |
613 GetNumOpenStreams() > | 613 DVLOG(1) << "Failed to create a new incoming stream with id:" << stream_id |
614 get_max_open_streams()) { | 614 << ". Already " << GetNumOpenStreams() |
615 DVLOG(1) << "Failed to create a new incoming stream with id:" | 615 << " streams open, would exceed max " << get_max_open_streams() |
616 << stream_id << ". Already " << GetNumOpenStreams() | 616 << "."; |
617 << " streams open, would exceed max " << get_max_open_streams() | 617 // We may already have sent a connection close due to multiple reset |
618 << "."; | 618 // streams in the same packet. |
619 // We may already have sent a connection close due to multiple reset | 619 if (connection()->connected()) { |
620 // streams in the same packet. | 620 connection()->SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS); |
621 if (connection()->connected()) { | |
622 connection()->SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS); | |
623 } | |
624 return nullptr; | |
625 } | 621 } |
626 } else { | 622 return nullptr; |
627 // Limit on the delta between stream IDs. | |
628 const QuicStreamId kMaxStreamIdDelta = 200; | |
629 if (stream_id - largest_peer_created_stream_id_ > kMaxStreamIdDelta) { | |
630 // We may already have sent a connection close due to multiple reset | |
631 // streams in the same packet. | |
632 if (connection()->connected()) { | |
633 LOG(ERROR) << "Trying to get stream: " << stream_id | |
634 << ", largest peer created stream: " | |
635 << largest_peer_created_stream_id_ | |
636 << ", max delta: " << kMaxStreamIdDelta; | |
637 connection()->SendConnectionClose(QUIC_INVALID_STREAM_ID); | |
638 } | |
639 return nullptr; | |
640 } | |
641 } | 623 } |
642 for (QuicStreamId id = largest_peer_created_stream_id_ + 2; | 624 for (QuicStreamId id = largest_peer_created_stream_id_ + 2; |
643 id < stream_id; | 625 id < stream_id; |
644 id += 2) { | 626 id += 2) { |
645 implicitly_created_streams_.insert(id); | 627 implicitly_created_streams_.insert(id); |
646 } | 628 } |
647 largest_peer_created_stream_id_ = stream_id; | 629 largest_peer_created_stream_id_ = stream_id; |
648 } | 630 } |
649 ReliableQuicStream* stream = CreateIncomingDynamicStream(stream_id); | 631 ReliableQuicStream* stream = CreateIncomingDynamicStream(stream_id); |
650 if (stream == nullptr) { | 632 if (stream == nullptr) { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 base::debug::StackTrace stack_trace = stack_trace_; | 743 base::debug::StackTrace stack_trace = stack_trace_; |
762 | 744 |
763 base::debug::Alias(&liveness); | 745 base::debug::Alias(&liveness); |
764 base::debug::Alias(&stack_trace); | 746 base::debug::Alias(&stack_trace); |
765 | 747 |
766 CHECK_EQ(ALIVE, liveness); | 748 CHECK_EQ(ALIVE, liveness); |
767 #endif | 749 #endif |
768 } | 750 } |
769 | 751 |
770 } // namespace net | 752 } // namespace net |
OLD | NEW |