| Index: net/quic/quic_connection.cc
|
| diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc
|
| index 5db2435a347d1ed4e7aec797aacaeb7bef52d6c6..e25c70097e454beec6baba9bb1ec72afc86afecc 100644
|
| --- a/net/quic/quic_connection.cc
|
| +++ b/net/quic/quic_connection.cc
|
| @@ -1911,44 +1911,49 @@ void QuicConnection::CheckForTimeout() {
|
| // |delta| can be < 0 as |now| is approximate time but |time_of_last_packet|
|
| // is accurate time. However, this should not change the behavior of
|
| // timeout handling.
|
| - QuicTime::Delta delta = now.Subtract(time_of_last_packet);
|
| + QuicTime::Delta idle_duration = now.Subtract(time_of_last_packet);
|
| DVLOG(1) << ENDPOINT << "last packet "
|
| << time_of_last_packet.ToDebuggingValue()
|
| << " now:" << now.ToDebuggingValue()
|
| - << " delta:" << delta.ToMicroseconds()
|
| - << " network_timeout: " << idle_network_timeout_.ToMicroseconds();
|
| - if (delta >= idle_network_timeout_) {
|
| + << " idle_duration:" << idle_duration.ToMicroseconds()
|
| + << " idle_network_timeout: "
|
| + << idle_network_timeout_.ToMicroseconds();
|
| + if (idle_duration >= idle_network_timeout_) {
|
| DVLOG(1) << ENDPOINT << "Connection timedout due to no network activity.";
|
| SendConnectionClose(QUIC_CONNECTION_TIMED_OUT);
|
| return;
|
| }
|
|
|
| - // Next timeout delta.
|
| - QuicTime::Delta timeout = idle_network_timeout_.Subtract(delta);
|
| -
|
| if (!overall_connection_timeout_.IsInfinite()) {
|
| - QuicTime::Delta connected_time =
|
| + QuicTime::Delta connected_duration =
|
| now.Subtract(stats_.connection_creation_time);
|
| DVLOG(1) << ENDPOINT << "connection time: "
|
| - << connected_time.ToMilliseconds() << " overall timeout: "
|
| - << overall_connection_timeout_.ToMilliseconds();
|
| - if (connected_time >= overall_connection_timeout_) {
|
| + << connected_duration.ToMicroseconds() << " overall timeout: "
|
| + << overall_connection_timeout_.ToMicroseconds();
|
| + if (connected_duration >= overall_connection_timeout_) {
|
| DVLOG(1) << ENDPOINT <<
|
| "Connection timedout due to overall connection timeout.";
|
| SendConnectionClose(QUIC_CONNECTION_OVERALL_TIMED_OUT);
|
| return;
|
| }
|
| + }
|
|
|
| - // Take the min timeout.
|
| - QuicTime::Delta connection_timeout =
|
| - overall_connection_timeout_.Subtract(connected_time);
|
| - if (connection_timeout < timeout) {
|
| - timeout = connection_timeout;
|
| - }
|
| + SetTimeoutAlarm();
|
| +}
|
| +
|
| +void QuicConnection::SetTimeoutAlarm() {
|
| + QuicTime time_of_last_packet = max(time_of_last_received_packet_,
|
| + time_of_last_sent_new_packet_);
|
| +
|
| + QuicTime deadline = time_of_last_packet.Add(idle_network_timeout_);
|
| + if (!overall_connection_timeout_.IsInfinite()) {
|
| + deadline = min(deadline,
|
| + stats_.connection_creation_time.Add(
|
| + overall_connection_timeout_));
|
| }
|
|
|
| timeout_alarm_->Cancel();
|
| - timeout_alarm_->Set(now.Add(timeout));
|
| + timeout_alarm_->Set(deadline);
|
| }
|
|
|
| void QuicConnection::SetPingAlarm() {
|
|
|