| Index: net/quic/quic_connection.cc
|
| diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc
|
| index a190865ffdd51f5d58a7cace220977e5bac6f15d..f0f66a98f0ab10085fec6c2f4671281562d86851 100644
|
| --- a/net/quic/quic_connection.cc
|
| +++ b/net/quic/quic_connection.cc
|
| @@ -216,8 +216,9 @@ QuicConnection::QuicConnection(QuicConnectionId connection_id,
|
| timeout_alarm_(helper->CreateAlarm(new TimeoutAlarm(this))),
|
| ping_alarm_(helper->CreateAlarm(new PingAlarm(this))),
|
| packet_generator_(connection_id_, &framer_, random_generator_, this),
|
| - idle_network_timeout_(
|
| - QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)),
|
| + idle_network_timeout_(FLAGS_quic_unified_timeouts ?
|
| + QuicTime::Delta::Infinite() :
|
| + QuicTime::Delta::FromSeconds(kDefaultIdleTimeoutSecs)),
|
| overall_connection_timeout_(QuicTime::Delta::Infinite()),
|
| time_of_last_received_packet_(clock_->ApproximateNow()),
|
| time_of_last_sent_new_packet_(clock_->ApproximateNow()),
|
| @@ -233,16 +234,11 @@ QuicConnection::QuicConnection(QuicConnectionId connection_id,
|
| peer_port_changed_(false),
|
| self_ip_changed_(false),
|
| self_port_changed_(false) {
|
| -#if 0
|
| - // TODO(rtenneti): Should we enable this code in chromium?
|
| - if (!is_server_) {
|
| - // Pacing will be enabled if the client negotiates it.
|
| - sent_packet_manager_.MaybeEnablePacing();
|
| - }
|
| -#endif
|
| DVLOG(1) << ENDPOINT << "Created connection with connection_id: "
|
| << connection_id;
|
| - timeout_alarm_->Set(clock_->ApproximateNow().Add(idle_network_timeout_));
|
| + if (!FLAGS_quic_unified_timeouts) {
|
| + timeout_alarm_->Set(clock_->ApproximateNow().Add(idle_network_timeout_));
|
| + }
|
| framer_.set_visitor(this);
|
| framer_.set_received_entropy_calculator(&received_packet_manager_);
|
| stats_.connection_creation_time = clock_->ApproximateNow();
|
| @@ -263,7 +259,17 @@ QuicConnection::~QuicConnection() {
|
| }
|
|
|
| void QuicConnection::SetFromConfig(const QuicConfig& config) {
|
| - SetIdleNetworkTimeout(config.IdleConnectionStateLifetime());
|
| + if (FLAGS_quic_unified_timeouts) {
|
| + if (config.negotiated()) {
|
| + SetNetworkTimeouts(QuicTime::Delta::Infinite(),
|
| + config.IdleConnectionStateLifetime());
|
| + } else {
|
| + SetNetworkTimeouts(config.max_time_before_crypto_handshake(),
|
| + config.max_idle_time_before_crypto_handshake());
|
| + }
|
| + } else {
|
| + SetIdleNetworkTimeout(config.IdleConnectionStateLifetime());
|
| + }
|
| sent_packet_manager_.SetFromConfig(config);
|
| }
|
|
|
| @@ -1880,6 +1886,24 @@ void QuicConnection::SetOverallConnectionTimeout(QuicTime::Delta timeout) {
|
| }
|
| }
|
|
|
| +void QuicConnection::SetNetworkTimeouts(QuicTime::Delta overall_timeout,
|
| + QuicTime::Delta idle_timeout) {
|
| + LOG_IF(DFATAL, idle_timeout > overall_timeout)
|
| + << "idle_timeout:" << idle_timeout.ToMilliseconds()
|
| + << " overall_timeout:" << overall_timeout.ToMilliseconds();
|
| + // Adjust the idle timeout on client and server to prevent clients from
|
| + // sending requests to servers which have already closed the connection.
|
| + if (is_server_) {
|
| + idle_timeout = idle_timeout.Add(QuicTime::Delta::FromSeconds(1));
|
| + } else if (idle_timeout > QuicTime::Delta::FromSeconds(1)) {
|
| + idle_timeout = idle_timeout.Subtract(QuicTime::Delta::FromSeconds(1));
|
| + }
|
| + overall_connection_timeout_ = overall_timeout;
|
| + idle_network_timeout_ = idle_timeout;
|
| +
|
| + SetTimeoutAlarm();
|
| +}
|
| +
|
| void QuicConnection::CheckForTimeout() {
|
| QuicTime now = clock_->ApproximateNow();
|
| QuicTime time_of_last_packet = max(time_of_last_received_packet_,
|
|
|