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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 return GetCryptoStream()->encryption_established(); | 469 return GetCryptoStream()->encryption_established(); |
470 } | 470 } |
471 | 471 |
472 bool QuicSession::IsCryptoHandshakeConfirmed() { | 472 bool QuicSession::IsCryptoHandshakeConfirmed() { |
473 return GetCryptoStream()->handshake_confirmed(); | 473 return GetCryptoStream()->handshake_confirmed(); |
474 } | 474 } |
475 | 475 |
476 void QuicSession::OnConfigNegotiated() { | 476 void QuicSession::OnConfigNegotiated() { |
477 connection_->SetFromConfig(config_); | 477 connection_->SetFromConfig(config_); |
478 QuicVersion version = connection()->version(); | 478 QuicVersion version = connection()->version(); |
| 479 |
| 480 // A server should accept a small number of additional streams beyond the |
| 481 // limit sent to the client. This helps avoid early connection termination |
| 482 // when FIN/RSTs for old streams are lost or arrive out of order. |
| 483 if (FLAGS_quic_allow_more_open_streams) { |
| 484 set_max_open_streams((is_server() ? kMaxStreamsMultiplier : 1.0) * |
| 485 config_.max_streams_per_connection()); |
| 486 } |
| 487 |
479 if (version <= QUIC_VERSION_16) { | 488 if (version <= QUIC_VERSION_16) { |
480 return; | 489 return; |
481 } | 490 } |
482 | 491 |
483 if (version <= QUIC_VERSION_19) { | 492 if (version <= QUIC_VERSION_19) { |
484 // QUIC_VERSION_17,18,19 don't support independent stream/session flow | 493 // QUIC_VERSION_17,18,19 don't support independent stream/session flow |
485 // control windows. | 494 // control windows. |
486 if (config_.HasReceivedInitialFlowControlWindowBytes()) { | 495 if (config_.HasReceivedInitialFlowControlWindowBytes()) { |
487 // Streams which were created before the SHLO was received (0-RTT | 496 // Streams which were created before the SHLO was received (0-RTT |
488 // requests) are now informed of the peer's initial flow control window. | 497 // requests) are now informed of the peer's initial flow control window. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 connection_->RetransmitUnackedPackets(ALL_INITIAL_RETRANSMISSION); | 566 connection_->RetransmitUnackedPackets(ALL_INITIAL_RETRANSMISSION); |
558 break; | 567 break; |
559 | 568 |
560 case HANDSHAKE_CONFIRMED: | 569 case HANDSHAKE_CONFIRMED: |
561 LOG_IF(DFATAL, !config_.negotiated()) << ENDPOINT | 570 LOG_IF(DFATAL, !config_.negotiated()) << ENDPOINT |
562 << "Handshake confirmed without parameter negotiation."; | 571 << "Handshake confirmed without parameter negotiation."; |
563 // Discard originally encrypted packets, since they can't be decrypted by | 572 // Discard originally encrypted packets, since they can't be decrypted by |
564 // the peer. | 573 // the peer. |
565 connection_->NeuterUnencryptedPackets(); | 574 connection_->NeuterUnencryptedPackets(); |
566 connection_->SetOverallConnectionTimeout(QuicTime::Delta::Infinite()); | 575 connection_->SetOverallConnectionTimeout(QuicTime::Delta::Infinite()); |
567 max_open_streams_ = config_.max_streams_per_connection(); | 576 if (!FLAGS_quic_allow_more_open_streams) { |
| 577 max_open_streams_ = config_.max_streams_per_connection(); |
| 578 } |
568 break; | 579 break; |
569 | 580 |
570 default: | 581 default: |
571 LOG(ERROR) << ENDPOINT << "Got unknown handshake event: " << event; | 582 LOG(ERROR) << ENDPOINT << "Got unknown handshake event: " << event; |
572 } | 583 } |
573 } | 584 } |
574 | 585 |
575 void QuicSession::OnCryptoHandshakeMessageSent( | 586 void QuicSession::OnCryptoHandshakeMessageSent( |
576 const CryptoHandshakeMessage& message) { | 587 const CryptoHandshakeMessage& message) { |
577 } | 588 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 largest_peer_created_stream_id_ = stream_id; | 683 largest_peer_created_stream_id_ = stream_id; |
673 } | 684 } |
674 QuicDataStream* stream = CreateIncomingDataStream(stream_id); | 685 QuicDataStream* stream = CreateIncomingDataStream(stream_id); |
675 if (stream == NULL) { | 686 if (stream == NULL) { |
676 return NULL; | 687 return NULL; |
677 } | 688 } |
678 ActivateStream(stream); | 689 ActivateStream(stream); |
679 return stream; | 690 return stream; |
680 } | 691 } |
681 | 692 |
| 693 void QuicSession::set_max_open_streams(size_t max_open_streams) { |
| 694 DVLOG(1) << "Setting max_open_streams_ to " << max_open_streams; |
| 695 max_open_streams_ = max_open_streams; |
| 696 } |
| 697 |
682 bool QuicSession::IsClosedStream(QuicStreamId id) { | 698 bool QuicSession::IsClosedStream(QuicStreamId id) { |
683 DCHECK_NE(0u, id); | 699 DCHECK_NE(0u, id); |
684 if (id == kCryptoStreamId) { | 700 if (id == kCryptoStreamId) { |
685 return false; | 701 return false; |
686 } | 702 } |
687 if (id == kHeadersStreamId) { | 703 if (id == kHeadersStreamId) { |
688 return false; | 704 return false; |
689 } | 705 } |
690 if (ContainsKey(stream_map_, id)) { | 706 if (ContainsKey(stream_map_, id)) { |
691 // Stream is active | 707 // Stream is active |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 } | 775 } |
760 for (DataStreamMap::iterator it = stream_map_.begin(); | 776 for (DataStreamMap::iterator it = stream_map_.begin(); |
761 it != stream_map_.end(); ++it) { | 777 it != stream_map_.end(); ++it) { |
762 if (version <= QUIC_VERSION_16) { | 778 if (version <= QUIC_VERSION_16) { |
763 it->second->flow_controller()->Disable(); | 779 it->second->flow_controller()->Disable(); |
764 } | 780 } |
765 } | 781 } |
766 } | 782 } |
767 | 783 |
768 } // namespace net | 784 } // namespace net |
OLD | NEW |