| 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 #include "net/quic/crypto/proof_verifier.h" | 8 #include "net/quic/crypto/proof_verifier.h" |
| 9 #include "net/quic/quic_connection.h" | 9 #include "net/quic/quic_connection.h" |
| 10 #include "net/quic/quic_flags.h" | 10 #include "net/quic/quic_flags.h" |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 } | 591 } |
| 592 | 592 |
| 593 return GetIncomingDynamicStream(stream_id); | 593 return GetIncomingDynamicStream(stream_id); |
| 594 } | 594 } |
| 595 | 595 |
| 596 ReliableQuicStream* QuicSession::GetIncomingDynamicStream( | 596 ReliableQuicStream* QuicSession::GetIncomingDynamicStream( |
| 597 QuicStreamId stream_id) { | 597 QuicStreamId stream_id) { |
| 598 if (IsClosedStream(stream_id)) { | 598 if (IsClosedStream(stream_id)) { |
| 599 return nullptr; | 599 return nullptr; |
| 600 } | 600 } |
| 601 | |
| 602 implicitly_created_streams_.erase(stream_id); | 601 implicitly_created_streams_.erase(stream_id); |
| 603 if (stream_id > largest_peer_created_stream_id_) { | 602 if (stream_id > largest_peer_created_stream_id_) { |
| 604 if (stream_id - largest_peer_created_stream_id_ > kMaxStreamIdDelta) { | 603 if (FLAGS_exact_stream_id_delta) { |
| 605 // We may already have sent a connection close due to multiple reset | 604 // Check if the number of streams that will be created (including |
| 606 // streams in the same packet. | 605 // implicitly open streams) would cause the number of open streams to |
| 607 if (connection()->connected()) { | 606 // exceed the limit. Note that the peer can create only |
| 608 LOG(ERROR) << "Trying to get stream: " << stream_id | 607 // alternately-numbered streams. |
| 609 << ", largest peer created stream: " | 608 if ((stream_id - largest_peer_created_stream_id_) / 2 + |
| 610 << largest_peer_created_stream_id_ | 609 GetNumOpenStreams() > |
| 611 << ", max delta: " << kMaxStreamIdDelta; | 610 get_max_open_streams()) { |
| 612 connection()->SendConnectionClose(QUIC_INVALID_STREAM_ID); | 611 DVLOG(1) << "Failed to create a new incoming stream with id:" |
| 612 << stream_id << ". Already " << GetNumOpenStreams() |
| 613 << " streams open, would exceed max " << get_max_open_streams() |
| 614 << "."; |
| 615 // We may already have sent a connection close due to multiple reset |
| 616 // streams in the same packet. |
| 617 if (connection()->connected()) { |
| 618 connection()->SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS); |
| 619 } |
| 620 return nullptr; |
| 613 } | 621 } |
| 614 return nullptr; | 622 } else { |
| 623 // Limit on the delta between stream IDs. |
| 624 const QuicStreamId kMaxStreamIdDelta = 200; |
| 625 if (stream_id - largest_peer_created_stream_id_ > kMaxStreamIdDelta) { |
| 626 // We may already have sent a connection close due to multiple reset |
| 627 // streams in the same packet. |
| 628 if (connection()->connected()) { |
| 629 LOG(ERROR) << "Trying to get stream: " << stream_id |
| 630 << ", largest peer created stream: " |
| 631 << largest_peer_created_stream_id_ |
| 632 << ", max delta: " << kMaxStreamIdDelta; |
| 633 connection()->SendConnectionClose(QUIC_INVALID_STREAM_ID); |
| 634 } |
| 635 return nullptr; |
| 636 } |
| 615 } | 637 } |
| 616 for (QuicStreamId id = largest_peer_created_stream_id_ + 2; | 638 for (QuicStreamId id = largest_peer_created_stream_id_ + 2; |
| 617 id < stream_id; | 639 id < stream_id; |
| 618 id += 2) { | 640 id += 2) { |
| 619 implicitly_created_streams_.insert(id); | 641 implicitly_created_streams_.insert(id); |
| 620 } | 642 } |
| 621 largest_peer_created_stream_id_ = stream_id; | 643 largest_peer_created_stream_id_ = stream_id; |
| 622 } | 644 } |
| 623 ReliableQuicStream* stream = CreateIncomingDynamicStream(stream_id); | 645 ReliableQuicStream* stream = CreateIncomingDynamicStream(stream_id); |
| 624 if (stream == nullptr) { | 646 if (stream == nullptr) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 } | 731 } |
| 710 for (auto const& kv : dynamic_stream_map_) { | 732 for (auto const& kv : dynamic_stream_map_) { |
| 711 if (kv.second->flow_controller()->IsBlocked()) { | 733 if (kv.second->flow_controller()->IsBlocked()) { |
| 712 return true; | 734 return true; |
| 713 } | 735 } |
| 714 } | 736 } |
| 715 return false; | 737 return false; |
| 716 } | 738 } |
| 717 | 739 |
| 718 } // namespace net | 740 } // namespace net |
| OLD | NEW |