| 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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 return GetIncomingDynamicStream(stream_id); | 624 return GetIncomingDynamicStream(stream_id); |
| 625 } | 625 } |
| 626 | 626 |
| 627 ReliableQuicStream* QuicSession::GetIncomingDynamicStream( | 627 ReliableQuicStream* QuicSession::GetIncomingDynamicStream( |
| 628 QuicStreamId stream_id) { | 628 QuicStreamId stream_id) { |
| 629 if (IsClosedStream(stream_id)) { | 629 if (IsClosedStream(stream_id)) { |
| 630 return nullptr; | 630 return nullptr; |
| 631 } | 631 } |
| 632 implicitly_created_streams_.erase(stream_id); | 632 implicitly_created_streams_.erase(stream_id); |
| 633 if (stream_id > largest_peer_created_stream_id_) { | 633 if (stream_id > largest_peer_created_stream_id_) { |
| 634 if (FLAGS_exact_stream_id_delta) { | 634 // Check if the number of streams that will be created (including implicitly |
| 635 // Check if the number of streams that will be created (including | 635 // open streams) would cause the number of open streams to exceed the limit. |
| 636 // implicitly open streams) would cause the number of open streams to | 636 // Note that the peer can create only alternately-numbered streams. |
| 637 // exceed the limit. Note that the peer can create only | 637 if ((stream_id - largest_peer_created_stream_id_) / 2 + |
| 638 // alternately-numbered streams. | 638 GetNumOpenStreams() > |
| 639 if ((stream_id - largest_peer_created_stream_id_) / 2 + | 639 get_max_open_streams()) { |
| 640 GetNumOpenStreams() > | 640 DVLOG(1) << "Failed to create a new incoming stream with id:" << stream_id |
| 641 get_max_open_streams()) { | 641 << ". Already " << GetNumOpenStreams() |
| 642 DVLOG(1) << "Failed to create a new incoming stream with id:" | 642 << " streams open, would exceed max " << get_max_open_streams() |
| 643 << stream_id << ". Already " << GetNumOpenStreams() | 643 << "."; |
| 644 << " streams open, would exceed max " << get_max_open_streams() | 644 // We may already have sent a connection close due to multiple reset |
| 645 << "."; | 645 // streams in the same packet. |
| 646 // We may already have sent a connection close due to multiple reset | 646 if (connection()->connected()) { |
| 647 // streams in the same packet. | 647 connection()->SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS); |
| 648 if (connection()->connected()) { | |
| 649 connection()->SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS); | |
| 650 } | |
| 651 return nullptr; | |
| 652 } | 648 } |
| 653 } else { | 649 return nullptr; |
| 654 // Limit on the delta between stream IDs. | |
| 655 const QuicStreamId kMaxStreamIdDelta = 200; | |
| 656 if (stream_id - largest_peer_created_stream_id_ > kMaxStreamIdDelta) { | |
| 657 // We may already have sent a connection close due to multiple reset | |
| 658 // streams in the same packet. | |
| 659 if (connection()->connected()) { | |
| 660 LOG(ERROR) << "Trying to get stream: " << stream_id | |
| 661 << ", largest peer created stream: " | |
| 662 << largest_peer_created_stream_id_ | |
| 663 << ", max delta: " << kMaxStreamIdDelta; | |
| 664 connection()->SendConnectionClose(QUIC_INVALID_STREAM_ID); | |
| 665 } | |
| 666 return nullptr; | |
| 667 } | |
| 668 } | 650 } |
| 669 for (QuicStreamId id = largest_peer_created_stream_id_ + 2; | 651 for (QuicStreamId id = largest_peer_created_stream_id_ + 2; |
| 670 id < stream_id; | 652 id < stream_id; |
| 671 id += 2) { | 653 id += 2) { |
| 672 implicitly_created_streams_.insert(id); | 654 implicitly_created_streams_.insert(id); |
| 673 } | 655 } |
| 674 largest_peer_created_stream_id_ = stream_id; | 656 largest_peer_created_stream_id_ = stream_id; |
| 675 } | 657 } |
| 676 ReliableQuicStream* stream = CreateIncomingDynamicStream(stream_id); | 658 ReliableQuicStream* stream = CreateIncomingDynamicStream(stream_id); |
| 677 if (stream == nullptr) { | 659 if (stream == nullptr) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 base::debug::StackTrace stack_trace = stack_trace_; | 770 base::debug::StackTrace stack_trace = stack_trace_; |
| 789 | 771 |
| 790 base::debug::Alias(&liveness); | 772 base::debug::Alias(&liveness); |
| 791 base::debug::Alias(&stack_trace); | 773 base::debug::Alias(&stack_trace); |
| 792 | 774 |
| 793 CHECK_EQ(ALIVE, liveness); | 775 CHECK_EQ(ALIVE, liveness); |
| 794 #endif | 776 #endif |
| 795 } | 777 } |
| 796 | 778 |
| 797 } // namespace net | 779 } // namespace net |
| OLD | NEW |