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/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 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 // If the incoming packet was missing, send an ack immediately. | 909 // If the incoming packet was missing, send an ack immediately. |
910 ack_queued_ = received_packet_manager_.IsMissing( | 910 ack_queued_ = received_packet_manager_.IsMissing( |
911 last_header_.packet_sequence_number); | 911 last_header_.packet_sequence_number); |
912 | 912 |
913 if (!ack_queued_ && ShouldLastPacketInstigateAck()) { | 913 if (!ack_queued_ && ShouldLastPacketInstigateAck()) { |
914 if (ack_alarm_->IsSet()) { | 914 if (ack_alarm_->IsSet()) { |
915 ack_queued_ = true; | 915 ack_queued_ = true; |
916 } else { | 916 } else { |
917 // Send an ack much more quickly for crypto handshake packets. | 917 // Send an ack much more quickly for crypto handshake packets. |
918 QuicTime::Delta delayed_ack_time = sent_packet_manager_.DelayedAckTime(); | 918 QuicTime::Delta delayed_ack_time = sent_packet_manager_.DelayedAckTime(); |
919 if (last_stream_frames_.size() == 1 && | |
920 last_stream_frames_[0].stream_id == kCryptoStreamId) { | |
921 delayed_ack_time = QuicTime::Delta::Zero(); | |
922 } | |
923 ack_alarm_->Set(clock_->ApproximateNow().Add(delayed_ack_time)); | 919 ack_alarm_->Set(clock_->ApproximateNow().Add(delayed_ack_time)); |
924 DVLOG(1) << "Ack timer set; next packet or timer will trigger ACK."; | 920 DVLOG(1) << "Ack timer set; next packet or timer will trigger ACK."; |
925 } | 921 } |
926 } | 922 } |
927 | 923 |
928 if (ack_queued_) { | 924 if (ack_queued_) { |
929 ack_alarm_->Cancel(); | 925 ack_alarm_->Cancel(); |
930 } | 926 } |
931 } | 927 } |
932 | 928 |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 } | 1598 } |
1603 | 1599 |
1604 void QuicConnection::OnCongestionWindowChange() { | 1600 void QuicConnection::OnCongestionWindowChange() { |
1605 packet_generator_.OnCongestionWindowChange( | 1601 packet_generator_.OnCongestionWindowChange( |
1606 sent_packet_manager_.EstimateMaxPacketsInFlight(max_packet_length())); | 1602 sent_packet_manager_.EstimateMaxPacketsInFlight(max_packet_length())); |
1607 visitor_->OnCongestionWindowChange(clock_->ApproximateNow()); | 1603 visitor_->OnCongestionWindowChange(clock_->ApproximateNow()); |
1608 } | 1604 } |
1609 | 1605 |
1610 void QuicConnection::OnHandshakeComplete() { | 1606 void QuicConnection::OnHandshakeComplete() { |
1611 sent_packet_manager_.SetHandshakeConfirmed(); | 1607 sent_packet_manager_.SetHandshakeConfirmed(); |
| 1608 // The client should immediately ack the SHLO to confirm the handshake is |
| 1609 // complete with the server. |
| 1610 if (!is_server_ && !ack_queued_) { |
| 1611 ack_alarm_->Cancel(); |
| 1612 ack_alarm_->Set(clock_->ApproximateNow()); |
| 1613 } |
1612 } | 1614 } |
1613 | 1615 |
1614 void QuicConnection::SendOrQueuePacket(QueuedPacket packet) { | 1616 void QuicConnection::SendOrQueuePacket(QueuedPacket packet) { |
1615 // The caller of this function is responsible for checking CanWrite(). | 1617 // The caller of this function is responsible for checking CanWrite(). |
1616 if (packet.serialized_packet.packet == nullptr) { | 1618 if (packet.serialized_packet.packet == nullptr) { |
1617 LOG(DFATAL) | 1619 LOG(DFATAL) |
1618 << "packet.serialized_packet.packet == nullptr in to SendOrQueuePacket"; | 1620 << "packet.serialized_packet.packet == nullptr in to SendOrQueuePacket"; |
1619 return; | 1621 return; |
1620 } | 1622 } |
1621 | 1623 |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2090 } | 2092 } |
2091 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { | 2093 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { |
2092 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { | 2094 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { |
2093 return true; | 2095 return true; |
2094 } | 2096 } |
2095 } | 2097 } |
2096 return false; | 2098 return false; |
2097 } | 2099 } |
2098 | 2100 |
2099 } // namespace net | 2101 } // namespace net |
OLD | NEW |