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

Side by Side Diff: net/quic/quic_connection.cc

Issue 571993002: Do not allow a QUIC connection to timeout if no packets have been sent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Minor_change_to_retransmission_75290729
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 unified diff | Download patch
« no previous file with comments | « no previous file | net/quic/quic_connection_test.cc » ('j') | net/quic/quic_flags.cc » ('J')
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 ack_alarm_(helper->CreateAlarm(new AckAlarm(this))), 200 ack_alarm_(helper->CreateAlarm(new AckAlarm(this))),
201 retransmission_alarm_(helper->CreateAlarm(new RetransmissionAlarm(this))), 201 retransmission_alarm_(helper->CreateAlarm(new RetransmissionAlarm(this))),
202 send_alarm_(helper->CreateAlarm(new SendAlarm(this))), 202 send_alarm_(helper->CreateAlarm(new SendAlarm(this))),
203 resume_writes_alarm_(helper->CreateAlarm(new SendAlarm(this))), 203 resume_writes_alarm_(helper->CreateAlarm(new SendAlarm(this))),
204 timeout_alarm_(helper->CreateAlarm(new TimeoutAlarm(this))), 204 timeout_alarm_(helper->CreateAlarm(new TimeoutAlarm(this))),
205 ping_alarm_(helper->CreateAlarm(new PingAlarm(this))), 205 ping_alarm_(helper->CreateAlarm(new PingAlarm(this))),
206 packet_generator_(connection_id_, &framer_, random_generator_, this), 206 packet_generator_(connection_id_, &framer_, random_generator_, this),
207 idle_network_timeout_( 207 idle_network_timeout_(
208 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)), 208 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)),
209 overall_connection_timeout_(QuicTime::Delta::Infinite()), 209 overall_connection_timeout_(QuicTime::Delta::Infinite()),
210 time_of_last_received_packet_(clock_->ApproximateNow()), 210 time_of_last_received_packet_(
211 time_of_last_sent_new_packet_(clock_->ApproximateNow()), 211 FLAGS_quic_timeouts_require_activity
212 ? QuicTime::Zero() : clock_->ApproximateNow()),
213 time_of_last_sent_new_packet_(
214 FLAGS_quic_timeouts_require_activity
215 ? QuicTime::Zero() : clock_->ApproximateNow()),
212 sequence_number_of_last_sent_packet_(0), 216 sequence_number_of_last_sent_packet_(0),
213 sent_packet_manager_( 217 sent_packet_manager_(
214 is_server, clock_, &stats_, 218 is_server, clock_, &stats_,
215 FLAGS_quic_use_bbr_congestion_control ? kBBR : kCubic, 219 FLAGS_quic_use_bbr_congestion_control ? kBBR : kCubic,
216 FLAGS_quic_use_time_loss_detection ? kTime : kNack), 220 FLAGS_quic_use_time_loss_detection ? kTime : kNack),
217 version_negotiation_state_(START_NEGOTIATION), 221 version_negotiation_state_(START_NEGOTIATION),
218 is_server_(is_server), 222 is_server_(is_server),
219 connected_(true), 223 connected_(true),
220 peer_ip_changed_(false), 224 peer_ip_changed_(false),
221 peer_port_changed_(false), 225 peer_port_changed_(false),
(...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 } else { 1886 } else {
1883 overall_connection_timeout_ = timeout; 1887 overall_connection_timeout_ = timeout;
1884 } 1888 }
1885 } 1889 }
1886 1890
1887 bool QuicConnection::CheckForTimeout() { 1891 bool QuicConnection::CheckForTimeout() {
1888 QuicTime now = clock_->ApproximateNow(); 1892 QuicTime now = clock_->ApproximateNow();
1889 QuicTime time_of_last_packet = max(time_of_last_received_packet_, 1893 QuicTime time_of_last_packet = max(time_of_last_received_packet_,
1890 time_of_last_sent_new_packet_); 1894 time_of_last_sent_new_packet_);
1891 1895
1896 // If no packets have been sent or recieved, then don't timeout.
1897 if (FLAGS_quic_timeouts_require_activity &&
1898 !time_of_last_packet.IsInitialized()) {
1899 timeout_alarm_->Cancel();
1900 timeout_alarm_->Set(now.Add(idle_network_timeout_));
1901 return false;
1902 }
1903
1892 // |delta| can be < 0 as |now| is approximate time but |time_of_last_packet| 1904 // |delta| can be < 0 as |now| is approximate time but |time_of_last_packet|
1893 // is accurate time. However, this should not change the behavior of 1905 // is accurate time. However, this should not change the behavior of
1894 // timeout handling. 1906 // timeout handling.
1895 QuicTime::Delta delta = now.Subtract(time_of_last_packet); 1907 QuicTime::Delta delta = now.Subtract(time_of_last_packet);
1896 DVLOG(1) << ENDPOINT << "last packet " 1908 DVLOG(1) << ENDPOINT << "last packet "
1897 << time_of_last_packet.ToDebuggingValue() 1909 << time_of_last_packet.ToDebuggingValue()
1898 << " now:" << now.ToDebuggingValue() 1910 << " now:" << now.ToDebuggingValue()
1899 << " delta:" << delta.ToMicroseconds() 1911 << " delta:" << delta.ToMicroseconds()
1900 << " network_timeout: " << idle_network_timeout_.ToMicroseconds(); 1912 << " network_timeout: " << idle_network_timeout_.ToMicroseconds();
1901 if (delta >= idle_network_timeout_) { 1913 if (delta >= idle_network_timeout_) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 } 2019 }
2008 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { 2020 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) {
2009 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { 2021 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) {
2010 return true; 2022 return true;
2011 } 2023 }
2012 } 2024 }
2013 return false; 2025 return false;
2014 } 2026 }
2015 2027
2016 } // namespace net 2028 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/quic_connection_test.cc » ('j') | net/quic/quic_flags.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698