Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(572)

Unified Diff: net/quic/quic_connection.cc

Issue 593193005: Factor out the QUIC timeout alarm setting logic from the CheckForTimeout (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Add_timestamp_field_75897792
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_connection.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « net/quic/quic_connection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698