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" |
11 #include "net/quic/quic_flow_controller.h" | 11 #include "net/quic/quic_flow_controller.h" |
12 #include "net/quic/quic_headers_stream.h" | 12 #include "net/quic/quic_headers_stream.h" |
13 #include "net/ssl/ssl_info.h" | 13 #include "net/ssl/ssl_info.h" |
14 | 14 |
15 using base::StringPiece; | 15 using base::StringPiece; |
16 using base::hash_map; | 16 using base::hash_map; |
17 using base::hash_set; | 17 using base::hash_set; |
18 using std::make_pair; | 18 using std::make_pair; |
| 19 using std::max; |
19 using std::vector; | 20 using std::vector; |
20 | 21 |
21 namespace net { | 22 namespace net { |
22 | 23 |
23 #define ENDPOINT (is_server() ? "Server: " : " Client: ") | 24 #define ENDPOINT (is_server() ? "Server: " : " Client: ") |
24 | 25 |
25 // We want to make sure we delete any closed streams in a safe manner. | 26 // We want to make sure we delete any closed streams in a safe manner. |
26 // To avoid deleting a stream in mid-operation, we have a simple shim between | 27 // To avoid deleting a stream in mid-operation, we have a simple shim between |
27 // us and the stream, so we can delete any streams when we return from | 28 // us and the stream, so we can delete any streams when we return from |
28 // processing. | 29 // processing. |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 } | 465 } |
465 | 466 |
466 bool QuicSession::IsCryptoHandshakeConfirmed() { | 467 bool QuicSession::IsCryptoHandshakeConfirmed() { |
467 return GetCryptoStream()->handshake_confirmed(); | 468 return GetCryptoStream()->handshake_confirmed(); |
468 } | 469 } |
469 | 470 |
470 void QuicSession::OnConfigNegotiated() { | 471 void QuicSession::OnConfigNegotiated() { |
471 connection_->SetFromConfig(config_); | 472 connection_->SetFromConfig(config_); |
472 QuicVersion version = connection()->version(); | 473 QuicVersion version = connection()->version(); |
473 | 474 |
474 // A server should accept a small number of additional streams beyond the | |
475 // limit sent to the client. This helps avoid early connection termination | |
476 // when FIN/RSTs for old streams are lost or arrive out of order. | |
477 if (FLAGS_quic_allow_more_open_streams) { | 475 if (FLAGS_quic_allow_more_open_streams) { |
478 set_max_open_streams((is_server() ? kMaxStreamsMultiplier : 1.0) * | 476 uint32 max_streams = config_.MaxStreamsPerConnection(); |
479 config_.MaxStreamsPerConnection()); | 477 if (is_server()) { |
| 478 // A server should accept a small number of additional streams beyond the |
| 479 // limit sent to the client. This helps avoid early connection termination |
| 480 // when FIN/RSTs for old streams are lost or arrive out of order. |
| 481 // Use a minimum number of additional streams, or a percentage increase, |
| 482 // whichever is larger. |
| 483 max_streams = |
| 484 max(max_streams + kMaxStreamsMinimumIncrement, |
| 485 static_cast<uint32>(max_streams * kMaxStreamsMultiplier)); |
| 486 } |
| 487 set_max_open_streams(max_streams); |
480 } | 488 } |
481 | 489 |
482 if (version <= QUIC_VERSION_16) { | 490 if (version <= QUIC_VERSION_16) { |
483 return; | 491 return; |
484 } | 492 } |
485 | 493 |
486 if (version <= QUIC_VERSION_19) { | 494 if (version <= QUIC_VERSION_19) { |
487 // QUIC_VERSION_17,18,19 don't support independent stream/session flow | 495 // QUIC_VERSION_17,18,19 don't support independent stream/session flow |
488 // control windows. | 496 // control windows. |
489 if (config_.HasReceivedInitialFlowControlWindowBytes()) { | 497 if (config_.HasReceivedInitialFlowControlWindowBytes()) { |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 } | 784 } |
777 for (DataStreamMap::iterator it = stream_map_.begin(); | 785 for (DataStreamMap::iterator it = stream_map_.begin(); |
778 it != stream_map_.end(); ++it) { | 786 it != stream_map_.end(); ++it) { |
779 if (version <= QUIC_VERSION_16) { | 787 if (version <= QUIC_VERSION_16) { |
780 it->second->flow_controller()->Disable(); | 788 it->second->flow_controller()->Disable(); |
781 } | 789 } |
782 } | 790 } |
783 } | 791 } |
784 | 792 |
785 } // namespace net | 793 } // namespace net |
OLD | NEW |