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