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

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

Issue 146033003: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 helper_(helper), 160 helper_(helper),
161 writer_(writer), 161 writer_(writer),
162 encryption_level_(ENCRYPTION_NONE), 162 encryption_level_(ENCRYPTION_NONE),
163 clock_(helper->GetClock()), 163 clock_(helper->GetClock()),
164 random_generator_(helper->GetRandomGenerator()), 164 random_generator_(helper->GetRandomGenerator()),
165 guid_(guid), 165 guid_(guid),
166 peer_address_(address), 166 peer_address_(address),
167 largest_seen_packet_with_ack_(0), 167 largest_seen_packet_with_ack_(0),
168 pending_version_negotiation_packet_(false), 168 pending_version_negotiation_packet_(false),
169 received_packet_manager_(kTCP), 169 received_packet_manager_(kTCP),
170 ack_queued_(false),
170 ack_alarm_(helper->CreateAlarm(new AckAlarm(this))), 171 ack_alarm_(helper->CreateAlarm(new AckAlarm(this))),
171 retransmission_alarm_(helper->CreateAlarm(new RetransmissionAlarm(this))), 172 retransmission_alarm_(helper->CreateAlarm(new RetransmissionAlarm(this))),
172 send_alarm_(helper->CreateAlarm(new SendAlarm(this))), 173 send_alarm_(helper->CreateAlarm(new SendAlarm(this))),
173 resume_writes_alarm_(helper->CreateAlarm(new SendAlarm(this))), 174 resume_writes_alarm_(helper->CreateAlarm(new SendAlarm(this))),
174 timeout_alarm_(helper->CreateAlarm(new TimeoutAlarm(this))), 175 timeout_alarm_(helper->CreateAlarm(new TimeoutAlarm(this))),
175 debug_visitor_(NULL), 176 debug_visitor_(NULL),
176 packet_creator_(guid_, &framer_, random_generator_, is_server), 177 packet_creator_(guid_, &framer_, random_generator_, is_server),
177 packet_generator_(this, NULL, &packet_creator_), 178 packet_generator_(this, NULL, &packet_creator_),
178 idle_network_timeout_( 179 idle_network_timeout_(
179 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)), 180 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)),
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 DVLOG(1) << ENDPOINT << (last_packet_revived_ ? "Revived" : "Got") 630 DVLOG(1) << ENDPOINT << (last_packet_revived_ ? "Revived" : "Got")
630 << " packet " << last_header_.packet_sequence_number 631 << " packet " << last_header_.packet_sequence_number
631 << " with " << last_ack_frames_.size() << " acks, " 632 << " with " << last_ack_frames_.size() << " acks, "
632 << last_congestion_frames_.size() << " congestions, " 633 << last_congestion_frames_.size() << " congestions, "
633 << last_goaway_frames_.size() << " goaways, " 634 << last_goaway_frames_.size() << " goaways, "
634 << last_rst_frames_.size() << " rsts, " 635 << last_rst_frames_.size() << " rsts, "
635 << last_close_frames_.size() << " closes, " 636 << last_close_frames_.size() << " closes, "
636 << last_stream_frames_.size() 637 << last_stream_frames_.size()
637 << " stream frames for " << last_header_.public_header.guid; 638 << " stream frames for " << last_header_.public_header.guid;
638 639
639 // Must called before ack processing, because processing acks removes entries 640 MaybeQueueAck();
640 // from unacket_packets_, increasing the least_unacked.
641 const bool last_packet_should_instigate_ack = ShouldLastPacketInstigateAck();
642
643 // If the incoming packet was missing, send an ack immediately.
644 bool send_ack_immediately = received_packet_manager_.IsMissing(
645 last_header_.packet_sequence_number);
646 641
647 // Discard the packet if the visitor fails to process the stream frames. 642 // Discard the packet if the visitor fails to process the stream frames.
648 if (!last_stream_frames_.empty() && 643 if (!last_stream_frames_.empty() &&
649 !visitor_->OnStreamFrames(last_stream_frames_)) { 644 !visitor_->OnStreamFrames(last_stream_frames_)) {
650 return; 645 return;
651 } 646 }
652 647
653 received_packet_manager_.RecordPacketReceived(last_size_, 648 received_packet_manager_.RecordPacketReceived(last_size_,
654 last_header_, 649 last_header_,
655 time_of_last_received_packet_, 650 time_of_last_received_packet_,
(...skipping 17 matching lines...) Expand all
673 sent_packet_manager_.OnIncomingQuicCongestionFeedbackFrame( 668 sent_packet_manager_.OnIncomingQuicCongestionFeedbackFrame(
674 last_congestion_frames_[i], time_of_last_received_packet_); 669 last_congestion_frames_[i], time_of_last_received_packet_);
675 } 670 }
676 if (!last_close_frames_.empty()) { 671 if (!last_close_frames_.empty()) {
677 CloseConnection(last_close_frames_[0].error_code, true); 672 CloseConnection(last_close_frames_[0].error_code, true);
678 DCHECK(!connected_); 673 DCHECK(!connected_);
679 } 674 }
680 675
681 // If there are new missing packets to report, send an ack immediately. 676 // If there are new missing packets to report, send an ack immediately.
682 if (received_packet_manager_.HasNewMissingPackets()) { 677 if (received_packet_manager_.HasNewMissingPackets()) {
683 send_ack_immediately = true; 678 ack_queued_ = true;
679 ack_alarm_->Cancel();
684 } 680 }
685 681
686 MaybeSendInResponseToPacket(send_ack_immediately, 682 ClearLastFrames();
687 last_packet_should_instigate_ack); 683 }
688 684
689 ClearLastFrames(); 685 void QuicConnection::MaybeQueueAck() {
686 // If the incoming packet was missing, send an ack immediately.
687 ack_queued_ = received_packet_manager_.IsMissing(
688 last_header_.packet_sequence_number);
689
690 // ShouldLastPacketInstigateAck must called before ack processing, because
691 // processing acks removes entries from unacket_packets_, increasing the
692 // least_unacked.
693 if (!ack_queued_ && ShouldLastPacketInstigateAck()) {
694 if (ack_alarm_->IsSet()) {
695 ack_queued_ = true;
696 } else {
697 ack_alarm_->Set(clock_->ApproximateNow().Add(
698 sent_packet_manager_.DelayedAckTime()));
699 DVLOG(1) << "Ack timer set; next packet or timer will trigger ACK.";
700 }
701 }
702
703 if (ack_queued_) {
704 ack_alarm_->Cancel();
705 }
690 } 706 }
691 707
692 void QuicConnection::ClearLastFrames() { 708 void QuicConnection::ClearLastFrames() {
693 last_stream_frames_.clear(); 709 last_stream_frames_.clear();
694 last_goaway_frames_.clear(); 710 last_goaway_frames_.clear();
695 last_rst_frames_.clear(); 711 last_rst_frames_.clear();
696 last_ack_frames_.clear(); 712 last_ack_frames_.clear();
697 last_congestion_frames_.clear(); 713 last_congestion_frames_.clear();
698 } 714 }
699 715
(...skipping 10 matching lines...) Expand all
710 return new QuicCongestionFeedbackFrame(outgoing_congestion_feedback_); 726 return new QuicCongestionFeedbackFrame(outgoing_congestion_feedback_);
711 } 727 }
712 728
713 bool QuicConnection::ShouldLastPacketInstigateAck() { 729 bool QuicConnection::ShouldLastPacketInstigateAck() {
714 if (!last_stream_frames_.empty() || 730 if (!last_stream_frames_.empty() ||
715 !last_goaway_frames_.empty() || 731 !last_goaway_frames_.empty() ||
716 !last_rst_frames_.empty()) { 732 !last_rst_frames_.empty()) {
717 return true; 733 return true;
718 } 734 }
719 735
720 // If the peer is still waiting for a packet that we are no 736 // If the peer is still waiting for a packet that we are no longer planning to
721 // longer planning to send, we should send an ack to raise 737 // send, send an ack to raise the high water mark.
722 // the high water mark.
723 if (!last_ack_frames_.empty() && 738 if (!last_ack_frames_.empty() &&
724 !last_ack_frames_.back().received_info.missing_packets.empty()) { 739 !last_ack_frames_.back().received_info.missing_packets.empty()) {
725 return sent_packet_manager_.GetLeastUnackedSentPacket() > 740 return sent_packet_manager_.GetLeastUnackedSentPacket() >
726 *last_ack_frames_.back().received_info.missing_packets.begin(); 741 *last_ack_frames_.back().received_info.missing_packets.begin();
727 } 742 }
728 return false; 743 return false;
729 } 744 }
730 745
731 void QuicConnection::MaybeSendInResponseToPacket( 746 void QuicConnection::MaybeSendInResponseToPacket() {
732 bool send_ack_immediately, 747 if (!connected_) {
733 bool last_packet_should_instigate_ack) { 748 return;
734 // |include_ack| is false since we decide about ack bundling below. 749 }
735 ScopedPacketBundler bundler(this, false); 750 ScopedPacketBundler bundler(this, false);
736 751 if (ack_queued_) {
737 if (last_packet_should_instigate_ack) { 752 SendAck();
738 // In general, we ack every second packet. When we don't ack the first
739 // packet, we set the delayed ack alarm. Thus, if the ack alarm is set
740 // then we know this is the second packet, and we should send an ack.
741 if (send_ack_immediately || ack_alarm_->IsSet()) {
742 SendAck();
743 DCHECK(!ack_alarm_->IsSet());
744 } else {
745 ack_alarm_->Set(clock_->ApproximateNow().Add(
746 sent_packet_manager_.DelayedAckTime()));
747 DVLOG(1) << "Ack timer set; next packet or timer will trigger ACK.";
748 }
749 } 753 }
750 754
751 if (!last_ack_frames_.empty()) { 755 // Now that we have received an ack, we might be able to send packets which
752 // Now the we have received an ack, we might be able to send packets which 756 // are queued locally, or drain streams which are blocked.
753 // are queued locally, or drain streams which are blocked. 757 QuicTime::Delta delay = sent_packet_manager_.TimeUntilSend(
754 QuicTime::Delta delay = sent_packet_manager_.TimeUntilSend( 758 time_of_last_received_packet_, NOT_RETRANSMISSION,
755 time_of_last_received_packet_, NOT_RETRANSMISSION, 759 HAS_RETRANSMITTABLE_DATA, NOT_HANDSHAKE);
756 HAS_RETRANSMITTABLE_DATA, NOT_HANDSHAKE); 760 if (delay.IsZero()) {
757 if (delay.IsZero()) { 761 send_alarm_->Cancel();
758 send_alarm_->Cancel(); 762 WriteIfNotBlocked();
759 WriteIfNotBlocked(); 763 } else if (!delay.IsInfinite()) {
760 } else if (!delay.IsInfinite()) { 764 send_alarm_->Cancel();
761 send_alarm_->Cancel(); 765 send_alarm_->Set(time_of_last_received_packet_.Add(delay));
762 send_alarm_->Set(time_of_last_received_packet_.Add(delay));
763 }
764 } 766 }
765 } 767 }
766 768
767 void QuicConnection::SendVersionNegotiationPacket() { 769 void QuicConnection::SendVersionNegotiationPacket() {
770 // TODO(alyssar): implement zero server state negotiation.
771 pending_version_negotiation_packet_ = true;
772 if (writer_->IsWriteBlocked()) {
773 visitor_->OnWriteBlocked();
774 return;
775 }
768 scoped_ptr<QuicEncryptedPacket> version_packet( 776 scoped_ptr<QuicEncryptedPacket> version_packet(
769 packet_creator_.SerializeVersionNegotiationPacket( 777 packet_creator_.SerializeVersionNegotiationPacket(
770 framer_.supported_versions())); 778 framer_.supported_versions()));
771 // TODO(satyamshekhar): implement zero server state negotiation. 779 WriteResult result = writer_->WritePacket(
772 WriteResult result = 780 version_packet->data(), version_packet->length(),
773 writer_->WritePacket(version_packet->data(), version_packet->length(), 781 self_address().address(), peer_address());
774 self_address().address(), peer_address(), this); 782
775 if (result.status == WRITE_STATUS_OK ||
776 (result.status == WRITE_STATUS_BLOCKED &&
777 writer_->IsWriteBlockedDataBuffered())) {
778 pending_version_negotiation_packet_ = false;
779 return;
780 }
781 if (result.status == WRITE_STATUS_ERROR) { 783 if (result.status == WRITE_STATUS_ERROR) {
782 // We can't send an error as the socket is presumably borked. 784 // We can't send an error as the socket is presumably borked.
783 CloseConnection(QUIC_PACKET_WRITE_ERROR, false); 785 CloseConnection(QUIC_PACKET_WRITE_ERROR, false);
786 return;
784 } 787 }
785 pending_version_negotiation_packet_ = true; 788 if (result.status == WRITE_STATUS_BLOCKED) {
789 visitor_->OnWriteBlocked();
790 if (writer_->IsWriteBlockedDataBuffered()) {
791 pending_version_negotiation_packet_ = false;
792 }
793 return;
794 }
795
796 pending_version_negotiation_packet_ = false;
786 } 797 }
787 798
788 QuicConsumedData QuicConnection::SendStreamData( 799 QuicConsumedData QuicConnection::SendStreamData(
789 QuicStreamId id, 800 QuicStreamId id,
790 const IOVector& data, 801 const IOVector& data,
791 QuicStreamOffset offset, 802 QuicStreamOffset offset,
792 bool fin, 803 bool fin,
793 QuicAckNotifier::DelegateInterface* delegate) { 804 QuicAckNotifier::DelegateInterface* delegate) {
794 if (!fin && data.Empty()) { 805 if (!fin && data.Empty()) {
795 LOG(DFATAL) << "Attempt to send empty stream frame"; 806 LOG(DFATAL) << "Attempt to send empty stream frame";
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 // because the CHLO or SHLO packet was lost. 877 // because the CHLO or SHLO packet was lost.
867 if (encryption_level_ != ENCRYPTION_FORWARD_SECURE && 878 if (encryption_level_ != ENCRYPTION_FORWARD_SECURE &&
868 framer_.error() == QUIC_DECRYPTION_FAILURE && 879 framer_.error() == QUIC_DECRYPTION_FAILURE &&
869 undecryptable_packets_.size() < kMaxUndecryptablePackets) { 880 undecryptable_packets_.size() < kMaxUndecryptablePackets) {
870 QueueUndecryptablePacket(packet); 881 QueueUndecryptablePacket(packet);
871 } 882 }
872 DVLOG(1) << ENDPOINT << "Unable to process packet. Last packet processed: " 883 DVLOG(1) << ENDPOINT << "Unable to process packet. Last packet processed: "
873 << last_header_.packet_sequence_number; 884 << last_header_.packet_sequence_number;
874 return; 885 return;
875 } 886 }
887
876 MaybeProcessUndecryptablePackets(); 888 MaybeProcessUndecryptablePackets();
877 MaybeProcessRevivedPacket(); 889 MaybeProcessRevivedPacket();
890 MaybeSendInResponseToPacket();
878 } 891 }
879 892
880 bool QuicConnection::OnCanWrite() { 893 bool QuicConnection::OnCanWrite() {
881 DCHECK(!writer_->IsWriteBlocked()); 894 DCHECK(!writer_->IsWriteBlocked());
882 895
883 WriteQueuedPackets(); 896 WriteQueuedPackets();
884 WritePendingRetransmissions(); 897 WritePendingRetransmissions();
885 898
886 IsHandshake pending_handshake = visitor_->HasPendingHandshake() ? 899 IsHandshake pending_handshake = visitor_->HasPendingHandshake() ?
887 IS_HANDSHAKE : NOT_HANDSHAKE; 900 IS_HANDSHAKE : NOT_HANDSHAKE;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 return true; 1033 return true;
1021 } 1034 }
1022 1035
1023 return CanWrite(transmission_type, retransmittable, handshake); 1036 return CanWrite(transmission_type, retransmittable, handshake);
1024 } 1037 }
1025 1038
1026 bool QuicConnection::CanWrite(TransmissionType transmission_type, 1039 bool QuicConnection::CanWrite(TransmissionType transmission_type,
1027 HasRetransmittableData retransmittable, 1040 HasRetransmittableData retransmittable,
1028 IsHandshake handshake) { 1041 IsHandshake handshake) {
1029 if (writer_->IsWriteBlocked()) { 1042 if (writer_->IsWriteBlocked()) {
1043 visitor_->OnWriteBlocked();
1030 return false; 1044 return false;
1031 } 1045 }
1032 1046
1033 // TODO(rch): consider removing this check so that if an ACK comes in 1047 // TODO(rch): consider removing this check so that if an ACK comes in
1034 // before the alarm goes it, we might be able send out a packet. 1048 // before the alarm goes it, we might be able send out a packet.
1035 // This check assumes that if the send alarm is set, it applies equally to all 1049 // This check assumes that if the send alarm is set, it applies equally to all
1036 // types of transmissions. 1050 // types of transmissions.
1037 if (send_alarm_->IsSet()) { 1051 if (send_alarm_->IsSet()) {
1038 DVLOG(1) << "Send alarm set. Not sending."; 1052 DVLOG(1) << "Send alarm set. Not sending.";
1039 return false; 1053 return false;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 // deleted at the end of this call. 1114 // deleted at the end of this call.
1101 scoped_ptr<QuicEncryptedPacket> encrypted_deleter; 1115 scoped_ptr<QuicEncryptedPacket> encrypted_deleter;
1102 if (forced == NO_FORCE) { 1116 if (forced == NO_FORCE) {
1103 encrypted_deleter.reset(encrypted); 1117 encrypted_deleter.reset(encrypted);
1104 } else { // forced == FORCE 1118 } else { // forced == FORCE
1105 DCHECK(connection_close_packet_.get() == NULL); 1119 DCHECK(connection_close_packet_.get() == NULL);
1106 connection_close_packet_.reset(encrypted); 1120 connection_close_packet_.reset(encrypted);
1107 // This assures we won't try to write *forced* packets when blocked. 1121 // This assures we won't try to write *forced* packets when blocked.
1108 // Return true to stop processing. 1122 // Return true to stop processing.
1109 if (writer_->IsWriteBlocked()) { 1123 if (writer_->IsWriteBlocked()) {
1124 visitor_->OnWriteBlocked();
1110 return true; 1125 return true;
1111 } 1126 }
1112 } 1127 }
1113 1128
1114 if (encrypted->length() > options()->max_packet_length) { 1129 if (encrypted->length() > options()->max_packet_length) {
1115 LOG(DFATAL) << "Writing an encrypted packet larger than max_packet_length:" 1130 LOG(DFATAL) << "Writing an encrypted packet larger than max_packet_length:"
1116 << options()->max_packet_length << " encrypted length: " 1131 << options()->max_packet_length << " encrypted length: "
1117 << encrypted->length(); 1132 << encrypted->length();
1118 } 1133 }
1119 DVLOG(1) << ENDPOINT << "Sending packet number " << sequence_number 1134 DVLOG(1) << ENDPOINT << "Sending packet number " << sequence_number
(...skipping 14 matching lines...) Expand all
1134 << " forced: " << (forced == FORCE ? "yes" : "no"); 1149 << " forced: " << (forced == FORCE ? "yes" : "no");
1135 1150
1136 DCHECK(pending_write_.get() == NULL); 1151 DCHECK(pending_write_.get() == NULL);
1137 pending_write_.reset(new PendingWrite(sequence_number, transmission_type, 1152 pending_write_.reset(new PendingWrite(sequence_number, transmission_type,
1138 retransmittable, level, 1153 retransmittable, level,
1139 packet.is_fec_packet(), 1154 packet.is_fec_packet(),
1140 packet.length())); 1155 packet.length()));
1141 1156
1142 WriteResult result = 1157 WriteResult result =
1143 writer_->WritePacket(encrypted->data(), encrypted->length(), 1158 writer_->WritePacket(encrypted->data(), encrypted->length(),
1144 self_address().address(), peer_address(), this); 1159 self_address().address(), peer_address());
1145 if (result.error_code == ERR_IO_PENDING) { 1160 if (result.error_code == ERR_IO_PENDING) {
1146 DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status); 1161 DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status);
1147 } 1162 }
1148 if (debug_visitor_) { 1163 if (debug_visitor_) {
1149 // Pass the write result to the visitor. 1164 // Pass the write result to the visitor.
1150 debug_visitor_->OnPacketSent(sequence_number, level, *encrypted, result); 1165 debug_visitor_->OnPacketSent(sequence_number, level, *encrypted, result);
1151 } 1166 }
1152 if (result.status == WRITE_STATUS_BLOCKED) { 1167 if (result.status == WRITE_STATUS_BLOCKED) {
1168 visitor_->OnWriteBlocked();
1153 // If the socket buffers the the data, then the packet should not 1169 // If the socket buffers the the data, then the packet should not
1154 // be queued and sent again, which would result in an unnecessary 1170 // be queued and sent again, which would result in an unnecessary
1155 // duplicate packet being sent. The helper must call OnPacketSent 1171 // duplicate packet being sent. The helper must call OnPacketSent
1156 // when the packet is actually sent. 1172 // when the packet is actually sent.
1157 if (writer_->IsWriteBlockedDataBuffered()) { 1173 if (writer_->IsWriteBlockedDataBuffered()) {
1158 return true; 1174 return true;
1159 } 1175 }
1160 pending_write_.reset(); 1176 pending_write_.reset();
1161 return false; 1177 return false;
1162 } 1178 }
(...skipping 25 matching lines...) Expand all
1188 } 1204 }
1189 1205
1190 // If the packet has been discarded before sending, don't send it. 1206 // If the packet has been discarded before sending, don't send it.
1191 // This occurs if a packet gets serialized, queued, then discarded. 1207 // This occurs if a packet gets serialized, queued, then discarded.
1192 if (!sent_packet_manager_.IsUnacked(sequence_number)) { 1208 if (!sent_packet_manager_.IsUnacked(sequence_number)) {
1193 DVLOG(1) << ENDPOINT << "Dropping packet before sending: " 1209 DVLOG(1) << ENDPOINT << "Dropping packet before sending: "
1194 << sequence_number << " since it has already been discarded."; 1210 << sequence_number << " since it has already been discarded.";
1195 return true; 1211 return true;
1196 } 1212 }
1197 1213
1198 if (retransmittable == HAS_RETRANSMITTABLE_DATA) { 1214 if (retransmittable == HAS_RETRANSMITTABLE_DATA &&
1199 if (sent_packet_manager_.IsPreviousTransmission(sequence_number)) { 1215 !sent_packet_manager_.HasRetransmittableFrames(sequence_number)) {
1200 // If somehow we have already retransmitted this packet *before* 1216 DVLOG(1) << ENDPOINT << "Dropping packet: " << sequence_number
1201 // we actually send it for the first time (I think this is probably 1217 << " since a previous transmission has been acked.";
1202 // impossible in the real world), then don't bother sending it. 1218 sent_packet_manager_.DiscardUnackedPacket(sequence_number);
1203 // We don't want to call DiscardUnackedPacket because in this case 1219 return true;
1204 // the peer has not yet ACK'd the data. We need the subsequent
1205 // retransmission to be sent.
1206 DVLOG(1) << ENDPOINT << "Dropping packet: " << sequence_number
1207 << " since it has already been retransmitted.";
1208 return true;
1209 }
1210
1211 if (!sent_packet_manager_.HasRetransmittableFrames(sequence_number)) {
1212 DVLOG(1) << ENDPOINT << "Dropping packet: " << sequence_number
1213 << " since a previous transmission has been acked.";
1214 sent_packet_manager_.DiscardUnackedPacket(sequence_number);
1215 return true;
1216 }
1217 } 1220 }
1218 1221
1219 return false; 1222 return false;
1220 } 1223 }
1221 1224
1222 bool QuicConnection::OnPacketSent(WriteResult result) { 1225 bool QuicConnection::OnPacketSent(WriteResult result) {
1223 DCHECK_NE(WRITE_STATUS_BLOCKED, result.status); 1226 DCHECK_NE(WRITE_STATUS_BLOCKED, result.status);
1224 if (pending_write_.get() == NULL) { 1227 if (pending_write_.get() == NULL) {
1225 LOG(DFATAL) << "OnPacketSent called without a pending write."; 1228 LOG(DFATAL) << "OnPacketSent called without a pending write.";
1226 return false; 1229 return false;
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 // If we changed the generator's batch state, restore original batch state. 1664 // If we changed the generator's batch state, restore original batch state.
1662 if (!already_in_batch_mode_) { 1665 if (!already_in_batch_mode_) {
1663 DVLOG(1) << "Leaving Batch Mode."; 1666 DVLOG(1) << "Leaving Batch Mode.";
1664 connection_->packet_generator_.FinishBatchOperations(); 1667 connection_->packet_generator_.FinishBatchOperations();
1665 } 1668 }
1666 DCHECK_EQ(already_in_batch_mode_, 1669 DCHECK_EQ(already_in_batch_mode_,
1667 connection_->packet_generator_.InBatchMode()); 1670 connection_->packet_generator_.InBatchMode());
1668 } 1671 }
1669 1672
1670 } // namespace net 1673 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698