| 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 "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 } | 624 } |
| 625 | 625 |
| 626 // Check if the new number of available streams would cause the number of | 626 // Check if the new number of available streams would cause the number of |
| 627 // available streams to exceed the limit. Note that the peer can create | 627 // available streams to exceed the limit. Note that the peer can create |
| 628 // only alternately-numbered streams. | 628 // only alternately-numbered streams. |
| 629 size_t additional_available_streams = | 629 size_t additional_available_streams = |
| 630 (stream_id - largest_peer_created_stream_id_) / 2 - 1; | 630 (stream_id - largest_peer_created_stream_id_) / 2 - 1; |
| 631 size_t new_num_available_streams = | 631 size_t new_num_available_streams = |
| 632 GetNumAvailableStreams() + additional_available_streams; | 632 GetNumAvailableStreams() + additional_available_streams; |
| 633 if (new_num_available_streams > MaxAvailableStreams()) { | 633 if (new_num_available_streams > MaxAvailableStreams()) { |
| 634 DVLOG(1) << "Failed to create a new incoming stream with id:" << stream_id | 634 DVLOG(1) << ENDPOINT |
| 635 << "Failed to create a new incoming stream with id:" << stream_id |
| 635 << ". There are already " << GetNumAvailableStreams() | 636 << ". There are already " << GetNumAvailableStreams() |
| 636 << " streams available, which would become " | 637 << " streams available, which would become " |
| 637 << new_num_available_streams << ", which exceeds the limit " | 638 << new_num_available_streams << ", which exceeds the limit " |
| 638 << MaxAvailableStreams() << "."; | 639 << MaxAvailableStreams() << "."; |
| 639 string details = IntToString(new_num_available_streams) + " above " + | 640 string details = IntToString(new_num_available_streams) + " above " + |
| 640 IntToString(MaxAvailableStreams()); | 641 IntToString(MaxAvailableStreams()); |
| 641 connection()->CloseConnection( | 642 connection()->CloseConnection( |
| 642 QUIC_TOO_MANY_AVAILABLE_STREAMS, details.c_str(), | 643 QUIC_TOO_MANY_AVAILABLE_STREAMS, details.c_str(), |
| 643 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 644 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 644 return false; | 645 return false; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 | 820 |
| 820 size_t QuicSession::MaxAvailableStreams() const { | 821 size_t QuicSession::MaxAvailableStreams() const { |
| 821 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; | 822 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; |
| 822 } | 823 } |
| 823 | 824 |
| 824 bool QuicSession::IsIncomingStream(QuicStreamId id) const { | 825 bool QuicSession::IsIncomingStream(QuicStreamId id) const { |
| 825 return id % 2 != next_outgoing_stream_id_ % 2; | 826 return id % 2 != next_outgoing_stream_id_ % 2; |
| 826 } | 827 } |
| 827 | 828 |
| 828 } // namespace net | 829 } // namespace net |
| OLD | NEW |