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

Side by Side 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, 2 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_connection.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 ack_queued_(false), 209 ack_queued_(false),
210 num_packets_received_since_last_ack_sent_(0), 210 num_packets_received_since_last_ack_sent_(0),
211 stop_waiting_count_(0), 211 stop_waiting_count_(0),
212 ack_alarm_(helper->CreateAlarm(new AckAlarm(this))), 212 ack_alarm_(helper->CreateAlarm(new AckAlarm(this))),
213 retransmission_alarm_(helper->CreateAlarm(new RetransmissionAlarm(this))), 213 retransmission_alarm_(helper->CreateAlarm(new RetransmissionAlarm(this))),
214 send_alarm_(helper->CreateAlarm(new SendAlarm(this))), 214 send_alarm_(helper->CreateAlarm(new SendAlarm(this))),
215 resume_writes_alarm_(helper->CreateAlarm(new SendAlarm(this))), 215 resume_writes_alarm_(helper->CreateAlarm(new SendAlarm(this))),
216 timeout_alarm_(helper->CreateAlarm(new TimeoutAlarm(this))), 216 timeout_alarm_(helper->CreateAlarm(new TimeoutAlarm(this))),
217 ping_alarm_(helper->CreateAlarm(new PingAlarm(this))), 217 ping_alarm_(helper->CreateAlarm(new PingAlarm(this))),
218 packet_generator_(connection_id_, &framer_, random_generator_, this), 218 packet_generator_(connection_id_, &framer_, random_generator_, this),
219 idle_network_timeout_( 219 idle_network_timeout_(FLAGS_quic_unified_timeouts ?
220 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)), 220 QuicTime::Delta::Infinite() :
221 QuicTime::Delta::FromSeconds(kDefaultIdleTimeoutSecs)),
221 overall_connection_timeout_(QuicTime::Delta::Infinite()), 222 overall_connection_timeout_(QuicTime::Delta::Infinite()),
222 time_of_last_received_packet_(clock_->ApproximateNow()), 223 time_of_last_received_packet_(clock_->ApproximateNow()),
223 time_of_last_sent_new_packet_(clock_->ApproximateNow()), 224 time_of_last_sent_new_packet_(clock_->ApproximateNow()),
224 sequence_number_of_last_sent_packet_(0), 225 sequence_number_of_last_sent_packet_(0),
225 sent_packet_manager_( 226 sent_packet_manager_(
226 is_server, clock_, &stats_, 227 is_server, clock_, &stats_,
227 FLAGS_quic_use_bbr_congestion_control ? kBBR : kCubic, 228 FLAGS_quic_use_bbr_congestion_control ? kBBR : kCubic,
228 FLAGS_quic_use_time_loss_detection ? kTime : kNack), 229 FLAGS_quic_use_time_loss_detection ? kTime : kNack),
229 version_negotiation_state_(START_NEGOTIATION), 230 version_negotiation_state_(START_NEGOTIATION),
230 is_server_(is_server), 231 is_server_(is_server),
231 connected_(true), 232 connected_(true),
232 peer_ip_changed_(false), 233 peer_ip_changed_(false),
233 peer_port_changed_(false), 234 peer_port_changed_(false),
234 self_ip_changed_(false), 235 self_ip_changed_(false),
235 self_port_changed_(false) { 236 self_port_changed_(false) {
236 #if 0
237 // TODO(rtenneti): Should we enable this code in chromium?
238 if (!is_server_) {
239 // Pacing will be enabled if the client negotiates it.
240 sent_packet_manager_.MaybeEnablePacing();
241 }
242 #endif
243 DVLOG(1) << ENDPOINT << "Created connection with connection_id: " 237 DVLOG(1) << ENDPOINT << "Created connection with connection_id: "
244 << connection_id; 238 << connection_id;
245 timeout_alarm_->Set(clock_->ApproximateNow().Add(idle_network_timeout_)); 239 if (!FLAGS_quic_unified_timeouts) {
240 timeout_alarm_->Set(clock_->ApproximateNow().Add(idle_network_timeout_));
241 }
246 framer_.set_visitor(this); 242 framer_.set_visitor(this);
247 framer_.set_received_entropy_calculator(&received_packet_manager_); 243 framer_.set_received_entropy_calculator(&received_packet_manager_);
248 stats_.connection_creation_time = clock_->ApproximateNow(); 244 stats_.connection_creation_time = clock_->ApproximateNow();
249 sent_packet_manager_.set_network_change_visitor(this); 245 sent_packet_manager_.set_network_change_visitor(this);
250 } 246 }
251 247
252 QuicConnection::~QuicConnection() { 248 QuicConnection::~QuicConnection() {
253 if (owns_writer_) { 249 if (owns_writer_) {
254 delete writer_; 250 delete writer_;
255 } 251 }
256 STLDeleteElements(&undecryptable_packets_); 252 STLDeleteElements(&undecryptable_packets_);
257 STLDeleteValues(&group_map_); 253 STLDeleteValues(&group_map_);
258 for (QueuedPacketList::iterator it = queued_packets_.begin(); 254 for (QueuedPacketList::iterator it = queued_packets_.begin();
259 it != queued_packets_.end(); ++it) { 255 it != queued_packets_.end(); ++it) {
260 delete it->serialized_packet.retransmittable_frames; 256 delete it->serialized_packet.retransmittable_frames;
261 delete it->serialized_packet.packet; 257 delete it->serialized_packet.packet;
262 } 258 }
263 } 259 }
264 260
265 void QuicConnection::SetFromConfig(const QuicConfig& config) { 261 void QuicConnection::SetFromConfig(const QuicConfig& config) {
266 SetIdleNetworkTimeout(config.IdleConnectionStateLifetime()); 262 if (FLAGS_quic_unified_timeouts) {
263 if (config.negotiated()) {
264 SetNetworkTimeouts(QuicTime::Delta::Infinite(),
265 config.IdleConnectionStateLifetime());
266 } else {
267 SetNetworkTimeouts(config.max_time_before_crypto_handshake(),
268 config.max_idle_time_before_crypto_handshake());
269 }
270 } else {
271 SetIdleNetworkTimeout(config.IdleConnectionStateLifetime());
272 }
267 sent_packet_manager_.SetFromConfig(config); 273 sent_packet_manager_.SetFromConfig(config);
268 } 274 }
269 275
270 bool QuicConnection::SelectMutualVersion( 276 bool QuicConnection::SelectMutualVersion(
271 const QuicVersionVector& available_versions) { 277 const QuicVersionVector& available_versions) {
272 // Try to find the highest mutual version by iterating over supported 278 // Try to find the highest mutual version by iterating over supported
273 // versions, starting with the highest, and breaking out of the loop once we 279 // versions, starting with the highest, and breaking out of the loop once we
274 // find a matching version in the provided available_versions vector. 280 // find a matching version in the provided available_versions vector.
275 const QuicVersionVector& supported_versions = framer_.supported_versions(); 281 const QuicVersionVector& supported_versions = framer_.supported_versions();
276 for (size_t i = 0; i < supported_versions.size(); ++i) { 282 for (size_t i = 0; i < supported_versions.size(); ++i) {
(...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 if (FLAGS_quic_timeouts_only_from_alarms) { 1879 if (FLAGS_quic_timeouts_only_from_alarms) {
1874 SetTimeoutAlarm(); 1880 SetTimeoutAlarm();
1875 } else { 1881 } else {
1876 CheckForTimeout(); 1882 CheckForTimeout();
1877 } 1883 }
1878 } else { 1884 } else {
1879 overall_connection_timeout_ = timeout; 1885 overall_connection_timeout_ = timeout;
1880 } 1886 }
1881 } 1887 }
1882 1888
1889 void QuicConnection::SetNetworkTimeouts(QuicTime::Delta overall_timeout,
1890 QuicTime::Delta idle_timeout) {
1891 LOG_IF(DFATAL, idle_timeout > overall_timeout)
1892 << "idle_timeout:" << idle_timeout.ToMilliseconds()
1893 << " overall_timeout:" << overall_timeout.ToMilliseconds();
1894 // Adjust the idle timeout on client and server to prevent clients from
1895 // sending requests to servers which have already closed the connection.
1896 if (is_server_) {
1897 idle_timeout = idle_timeout.Add(QuicTime::Delta::FromSeconds(1));
1898 } else if (idle_timeout > QuicTime::Delta::FromSeconds(1)) {
1899 idle_timeout = idle_timeout.Subtract(QuicTime::Delta::FromSeconds(1));
1900 }
1901 overall_connection_timeout_ = overall_timeout;
1902 idle_network_timeout_ = idle_timeout;
1903
1904 SetTimeoutAlarm();
1905 }
1906
1883 void QuicConnection::CheckForTimeout() { 1907 void QuicConnection::CheckForTimeout() {
1884 QuicTime now = clock_->ApproximateNow(); 1908 QuicTime now = clock_->ApproximateNow();
1885 QuicTime time_of_last_packet = max(time_of_last_received_packet_, 1909 QuicTime time_of_last_packet = max(time_of_last_received_packet_,
1886 time_of_last_sent_new_packet_); 1910 time_of_last_sent_new_packet_);
1887 1911
1888 // |delta| can be < 0 as |now| is approximate time but |time_of_last_packet| 1912 // |delta| can be < 0 as |now| is approximate time but |time_of_last_packet|
1889 // is accurate time. However, this should not change the behavior of 1913 // is accurate time. However, this should not change the behavior of
1890 // timeout handling. 1914 // timeout handling.
1891 QuicTime::Delta idle_duration = now.Subtract(time_of_last_packet); 1915 QuicTime::Delta idle_duration = now.Subtract(time_of_last_packet);
1892 DVLOG(1) << ENDPOINT << "last packet " 1916 DVLOG(1) << ENDPOINT << "last packet "
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 } 2031 }
2008 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { 2032 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) {
2009 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { 2033 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) {
2010 return true; 2034 return true;
2011 } 2035 }
2012 } 2036 }
2013 return false; 2037 return false;
2014 } 2038 }
2015 2039
2016 } // namespace net 2040 } // namespace net
OLDNEW
« 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