OLD | NEW |
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/core/quic_connection.h" | 5 #include "net/quic/core/quic_connection.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 } | 1705 } |
1706 | 1706 |
1707 if (result.status != WRITE_STATUS_ERROR && debug_visitor_ != nullptr) { | 1707 if (result.status != WRITE_STATUS_ERROR && debug_visitor_ != nullptr) { |
1708 // Pass the write result to the visitor. | 1708 // Pass the write result to the visitor. |
1709 debug_visitor_->OnPacketSent(*packet, packet->original_path_id, | 1709 debug_visitor_->OnPacketSent(*packet, packet->original_path_id, |
1710 packet->original_packet_number, | 1710 packet->original_packet_number, |
1711 packet->transmission_type, packet_send_time); | 1711 packet->transmission_type, packet_send_time); |
1712 } | 1712 } |
1713 if (packet->transmission_type == NOT_RETRANSMISSION) { | 1713 if (packet->transmission_type == NOT_RETRANSMISSION) { |
1714 time_of_last_sent_new_packet_ = packet_send_time; | 1714 time_of_last_sent_new_packet_ = packet_send_time; |
1715 if (!FLAGS_quic_better_last_send_for_timeout) { | |
1716 if (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA && | |
1717 last_send_for_timeout_ <= time_of_last_received_packet_) { | |
1718 last_send_for_timeout_ = packet_send_time; | |
1719 } | |
1720 } | |
1721 } | 1715 } |
1722 if (FLAGS_quic_better_last_send_for_timeout) { | 1716 // Only adjust the last sent time (for the purpose of tracking the idle |
1723 // Only adjust the last sent time (for the purpose of tracking the idle | 1717 // timeout) if this is the first retransmittable packet sent after a |
1724 // timeout) if this is the first retransmittable packet sent after a | 1718 // packet is received. If it were updated on every sent packet, then |
1725 // packet is received. If it were updated on every sent packet, then | 1719 // sending into a black hole might never timeout. |
1726 // sending into a black hole might never timeout. | 1720 if (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA && |
1727 if (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA && | 1721 last_send_for_timeout_ <= time_of_last_received_packet_) { |
1728 last_send_for_timeout_ <= time_of_last_received_packet_) { | 1722 last_send_for_timeout_ = packet_send_time; |
1729 last_send_for_timeout_ = packet_send_time; | |
1730 } | |
1731 } | 1723 } |
1732 SetPingAlarm(); | 1724 SetPingAlarm(); |
1733 MaybeSetMtuAlarm(); | 1725 MaybeSetMtuAlarm(); |
1734 DVLOG(1) << ENDPOINT << "time we began writing last sent packet: " | 1726 DVLOG(1) << ENDPOINT << "time we began writing last sent packet: " |
1735 << packet_send_time.ToDebuggingValue(); | 1727 << packet_send_time.ToDebuggingValue(); |
1736 | 1728 |
1737 bool reset_retransmission_alarm = sent_packet_manager_->OnPacketSent( | 1729 bool reset_retransmission_alarm = sent_packet_manager_->OnPacketSent( |
1738 packet, packet->original_path_id, packet->original_packet_number, | 1730 packet, packet->original_path_id, packet->original_packet_number, |
1739 packet_send_time, packet->transmission_type, IsRetransmittable(*packet)); | 1731 packet_send_time, packet->transmission_type, IsRetransmittable(*packet)); |
1740 | 1732 |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2229 return; | 2221 return; |
2230 } | 2222 } |
2231 } | 2223 } |
2232 | 2224 |
2233 SetTimeoutAlarm(); | 2225 SetTimeoutAlarm(); |
2234 } | 2226 } |
2235 | 2227 |
2236 void QuicConnection::SetTimeoutAlarm() { | 2228 void QuicConnection::SetTimeoutAlarm() { |
2237 QuicTime time_of_last_packet = | 2229 QuicTime time_of_last_packet = |
2238 max(time_of_last_received_packet_, time_of_last_sent_new_packet_); | 2230 max(time_of_last_received_packet_, time_of_last_sent_new_packet_); |
2239 if (FLAGS_quic_better_last_send_for_timeout) { | 2231 time_of_last_packet = |
2240 time_of_last_packet = | 2232 max(time_of_last_received_packet_, last_send_for_timeout_); |
2241 max(time_of_last_received_packet_, last_send_for_timeout_); | |
2242 } | |
2243 | 2233 |
2244 QuicTime deadline = time_of_last_packet + idle_network_timeout_; | 2234 QuicTime deadline = time_of_last_packet + idle_network_timeout_; |
2245 if (!handshake_timeout_.IsInfinite()) { | 2235 if (!handshake_timeout_.IsInfinite()) { |
2246 deadline = | 2236 deadline = |
2247 min(deadline, stats_.connection_creation_time + handshake_timeout_); | 2237 min(deadline, stats_.connection_creation_time + handshake_timeout_); |
2248 } | 2238 } |
2249 | 2239 |
2250 timeout_alarm_->Update(deadline, QuicTime::Delta::Zero()); | 2240 timeout_alarm_->Update(deadline, QuicTime::Delta::Zero()); |
2251 } | 2241 } |
2252 | 2242 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2568 | 2558 |
2569 void QuicConnection::CheckIfApplicationLimited() { | 2559 void QuicConnection::CheckIfApplicationLimited() { |
2570 if (queued_packets_.empty() && | 2560 if (queued_packets_.empty() && |
2571 !sent_packet_manager_->HasPendingRetransmissions() && | 2561 !sent_packet_manager_->HasPendingRetransmissions() && |
2572 !visitor_->WillingAndAbleToWrite()) { | 2562 !visitor_->WillingAndAbleToWrite()) { |
2573 sent_packet_manager_->OnApplicationLimited(); | 2563 sent_packet_manager_->OnApplicationLimited(); |
2574 } | 2564 } |
2575 } | 2565 } |
2576 | 2566 |
2577 } // namespace net | 2567 } // namespace net |
OLD | NEW |