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

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

Issue 133683010: Fix a bug where the packet was put into unacked packets when it was (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_sent_packet_manager.h" 5 #include "net/quic/quic_sent_packet_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "net/quic/congestion_control/pacing_sender.h" 9 #include "net/quic/congestion_control/pacing_sender.h"
10 #include "net/quic/quic_ack_notifier_manager.h" 10 #include "net/quic/quic_ack_notifier_manager.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 void QuicSentPacketManager::RetransmitUnackedPackets( 295 void QuicSentPacketManager::RetransmitUnackedPackets(
296 RetransmissionType retransmission_type) { 296 RetransmissionType retransmission_type) {
297 if (unacked_packets_.empty()) { 297 if (unacked_packets_.empty()) {
298 return; 298 return;
299 } 299 }
300 300
301 for (UnackedPacketMap::iterator unacked_it = unacked_packets_.begin(); 301 for (UnackedPacketMap::iterator unacked_it = unacked_packets_.begin();
302 unacked_it != unacked_packets_.end(); ++unacked_it) { 302 unacked_it != unacked_packets_.end(); ++unacked_it) {
303 const RetransmittableFrames* frames = 303 const RetransmittableFrames* frames =
304 unacked_it->second.retransmittable_frames; 304 unacked_it->second.retransmittable_frames;
305 if (frames == NULL) {
306 continue;
307 }
308 if (retransmission_type == ALL_PACKETS || 305 if (retransmission_type == ALL_PACKETS ||
309 frames->encryption_level() == ENCRYPTION_INITIAL) { 306 (frames != NULL && frames->encryption_level() == ENCRYPTION_INITIAL)) {
310 // TODO(satyamshekhar): Think about congestion control here. 307 if (frames) {
311 // Specifically, about the retransmission count of packets being sent
312 // proactively to achieve 0 (minimal) RTT.
313 if (unacked_it->second.retransmittable_frames) {
314 OnPacketAbandoned(unacked_it); 308 OnPacketAbandoned(unacked_it);
315 MarkForRetransmission(unacked_it->first, NACK_RETRANSMISSION); 309 MarkForRetransmission(unacked_it->first, NACK_RETRANSMISSION);
316 } else { 310 } else {
317 DiscardUnackedPacket(unacked_it->first); 311 DiscardUnackedPacket(unacked_it->first);
318 } 312 }
319 } 313 }
320 } 314 }
321 } 315 }
322 316
323 void QuicSentPacketManager::MarkForRetransmission( 317 void QuicSentPacketManager::MarkForRetransmission(
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 return unacked_packets; 535 return unacked_packets;
542 } 536 }
543 537
544 bool QuicSentPacketManager::OnPacketSent( 538 bool QuicSentPacketManager::OnPacketSent(
545 QuicPacketSequenceNumber sequence_number, 539 QuicPacketSequenceNumber sequence_number,
546 QuicTime sent_time, 540 QuicTime sent_time,
547 QuicByteCount bytes, 541 QuicByteCount bytes,
548 TransmissionType transmission_type, 542 TransmissionType transmission_type,
549 HasRetransmittableData has_retransmittable_data) { 543 HasRetransmittableData has_retransmittable_data) {
550 DCHECK_LT(0u, sequence_number); 544 DCHECK_LT(0u, sequence_number);
551 // In some edge cases, on some platforms (such as Windows), it is possible 545 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number);
552 // that we were write-blocked when we tried to send a packet, and then decided 546 // In rare circumstances, the packet could be serialized, sent, and then acked
553 // not to send the packet (such as when the encryption key changes, and we 547 // before OnPacketSent is called.
554 // "discard" the unsent packet). In that rare case, we may indeed 548 if (it == unacked_packets_.end()) {
555 // asynchronously (later) send the packet, calling this method, but the
556 // sequence number may already be erased from unacked_packets_ map. In that
557 // case, we can just return false since the packet will not be tracked for
558 // retransmission.
559 if (!ContainsKey(unacked_packets_, sequence_number))
560 return false; 549 return false;
561 DCHECK(!unacked_packets_[sequence_number].pending); 550 }
562 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number); 551 DCHECK(!it->second.pending);
563 552
564 // Only track packets the send algorithm wants us to track. 553 // Only track packets the send algorithm wants us to track.
565 if (!send_algorithm_->OnPacketSent(sent_time, sequence_number, bytes, 554 if (!send_algorithm_->OnPacketSent(sent_time, sequence_number, bytes,
566 transmission_type, 555 transmission_type,
567 has_retransmittable_data)) { 556 has_retransmittable_data)) {
568 DCHECK(it->second.retransmittable_frames == NULL); 557 DCHECK(it->second.retransmittable_frames == NULL);
569 unacked_packets_.erase(it); 558 unacked_packets_.erase(it);
570 // Do not reset the retransmission timer, since the packet isn't tracked. 559 // Do not reset the retransmission timer, since the packet isn't tracked.
571 return false; 560 return false;
572 } 561 }
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 } 984 }
996 previous_transmissions->erase(sequence_number); 985 previous_transmissions->erase(sequence_number);
997 if (previous_transmissions->size() == 1) { 986 if (previous_transmissions->size() == 1) {
998 QuicPacketSequenceNumber current = *previous_transmissions->begin(); 987 QuicPacketSequenceNumber current = *previous_transmissions->begin();
999 unacked_packets_[current].previous_transmissions = NULL; 988 unacked_packets_[current].previous_transmissions = NULL;
1000 delete previous_transmissions; 989 delete previous_transmissions;
1001 } 990 }
1002 } 991 }
1003 992
1004 } // namespace net 993 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698