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 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 } | 1658 } |
1659 } | 1659 } |
1660 if (result.status != WRITE_STATUS_ERROR && debug_visitor_ != nullptr) { | 1660 if (result.status != WRITE_STATUS_ERROR && debug_visitor_ != nullptr) { |
1661 // Pass the write result to the visitor. | 1661 // Pass the write result to the visitor. |
1662 debug_visitor_->OnPacketSent(*packet, packet->original_path_id, | 1662 debug_visitor_->OnPacketSent(*packet, packet->original_path_id, |
1663 packet->original_packet_number, | 1663 packet->original_packet_number, |
1664 packet->transmission_type, packet_send_time); | 1664 packet->transmission_type, packet_send_time); |
1665 } | 1665 } |
1666 if (packet->transmission_type == NOT_RETRANSMISSION) { | 1666 if (packet->transmission_type == NOT_RETRANSMISSION) { |
1667 time_of_last_sent_new_packet_ = packet_send_time; | 1667 time_of_last_sent_new_packet_ = packet_send_time; |
| 1668 if (!FLAGS_quic_better_last_send_for_timeout) { |
| 1669 if (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA && |
| 1670 last_send_for_timeout_ <= time_of_last_received_packet_) { |
| 1671 last_send_for_timeout_ = packet_send_time; |
| 1672 } |
| 1673 } |
| 1674 } |
| 1675 if (FLAGS_quic_better_last_send_for_timeout) { |
| 1676 // Only adjust the last sent time (for the purpose of tracking the idle |
| 1677 // timeout) if this is the first retransmittable packet sent after a |
| 1678 // packet is received. If it were updated on every sent packet, then |
| 1679 // sending into a black hole might never timeout. |
1668 if (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA && | 1680 if (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA && |
1669 last_send_for_timeout_ <= time_of_last_received_packet_) { | 1681 last_send_for_timeout_ <= time_of_last_received_packet_) { |
1670 last_send_for_timeout_ = packet_send_time; | 1682 last_send_for_timeout_ = packet_send_time; |
1671 } | 1683 } |
1672 } | 1684 } |
1673 SetPingAlarm(); | 1685 SetPingAlarm(); |
1674 MaybeSetMtuAlarm(); | 1686 MaybeSetMtuAlarm(); |
1675 DVLOG(1) << ENDPOINT << "time we began writing last sent packet: " | 1687 DVLOG(1) << ENDPOINT << "time we began writing last sent packet: " |
1676 << packet_send_time.ToDebuggingValue(); | 1688 << packet_send_time.ToDebuggingValue(); |
1677 | 1689 |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2200 return; | 2212 return; |
2201 } | 2213 } |
2202 } | 2214 } |
2203 | 2215 |
2204 SetTimeoutAlarm(); | 2216 SetTimeoutAlarm(); |
2205 } | 2217 } |
2206 | 2218 |
2207 void QuicConnection::SetTimeoutAlarm() { | 2219 void QuicConnection::SetTimeoutAlarm() { |
2208 QuicTime time_of_last_packet = | 2220 QuicTime time_of_last_packet = |
2209 max(time_of_last_received_packet_, time_of_last_sent_new_packet_); | 2221 max(time_of_last_received_packet_, time_of_last_sent_new_packet_); |
| 2222 if (FLAGS_quic_better_last_send_for_timeout) { |
| 2223 time_of_last_packet = |
| 2224 max(time_of_last_received_packet_, last_send_for_timeout_); |
| 2225 } |
2210 | 2226 |
2211 QuicTime deadline = time_of_last_packet + idle_network_timeout_; | 2227 QuicTime deadline = time_of_last_packet + idle_network_timeout_; |
2212 if (!handshake_timeout_.IsInfinite()) { | 2228 if (!handshake_timeout_.IsInfinite()) { |
2213 deadline = | 2229 deadline = |
2214 min(deadline, stats_.connection_creation_time + handshake_timeout_); | 2230 min(deadline, stats_.connection_creation_time + handshake_timeout_); |
2215 } | 2231 } |
2216 | 2232 |
2217 timeout_alarm_->Update(deadline, QuicTime::Delta::Zero()); | 2233 timeout_alarm_->Update(deadline, QuicTime::Delta::Zero()); |
2218 } | 2234 } |
2219 | 2235 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2538 | 2554 |
2539 void QuicConnection::CheckIfApplicationLimited() { | 2555 void QuicConnection::CheckIfApplicationLimited() { |
2540 if (queued_packets_.empty() && | 2556 if (queued_packets_.empty() && |
2541 !sent_packet_manager_->HasPendingRetransmissions() && | 2557 !sent_packet_manager_->HasPendingRetransmissions() && |
2542 !visitor_->WillingAndAbleToWrite()) { | 2558 !visitor_->WillingAndAbleToWrite()) { |
2543 sent_packet_manager_->OnApplicationLimited(); | 2559 sent_packet_manager_->OnApplicationLimited(); |
2544 } | 2560 } |
2545 } | 2561 } |
2546 | 2562 |
2547 } // namespace net | 2563 } // namespace net |
OLD | NEW |