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

Unified Diff: net/quic/quic_connection.cc

Issue 610073002: Change the pre-handshake idle timeout to 5s from 120s, and the default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Add_a_convenience_method_76423808
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') | net/quic/quic_connection_test.cc » ('j') | 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 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_,
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698