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

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

Issue 512933005: Fix a QUIC bug in which PING frames were not being ACK'd. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 // Packets that we cannot decrypt are dropped. 293 // Packets that we cannot decrypt are dropped.
294 // TODO(rch): add stats to measure this. 294 // TODO(rch): add stats to measure this.
295 if (!connected_ || framer->error() == QUIC_DECRYPTION_FAILURE) { 295 if (!connected_ || framer->error() == QUIC_DECRYPTION_FAILURE) {
296 return; 296 return;
297 } 297 }
298 SendConnectionCloseWithDetails(framer->error(), framer->detailed_error()); 298 SendConnectionCloseWithDetails(framer->error(), framer->detailed_error());
299 } 299 }
300 300
301 void QuicConnection::OnPacket() { 301 void QuicConnection::OnPacket() {
302 DCHECK(last_stream_frames_.empty() && 302 DCHECK(last_stream_frames_.empty() &&
303 last_ack_frames_.empty() &&
304 last_congestion_frames_.empty() &&
305 last_stop_waiting_frames_.empty() &&
306 last_rst_frames_.empty() &&
303 last_goaway_frames_.empty() && 307 last_goaway_frames_.empty() &&
304 last_window_update_frames_.empty() && 308 last_window_update_frames_.empty() &&
305 last_blocked_frames_.empty() && 309 last_blocked_frames_.empty() &&
306 last_rst_frames_.empty() && 310 last_ping_frames_.empty() &&
307 last_ack_frames_.empty() && 311 last_close_frames_.empty());
308 last_congestion_frames_.empty() &&
309 last_stop_waiting_frames_.empty());
310 } 312 }
311 313
312 void QuicConnection::OnPublicResetPacket( 314 void QuicConnection::OnPublicResetPacket(
313 const QuicPublicResetPacket& packet) { 315 const QuicPublicResetPacket& packet) {
314 if (debug_visitor_.get() != NULL) { 316 if (debug_visitor_.get() != NULL) {
315 debug_visitor_->OnPublicResetPacket(packet); 317 debug_visitor_->OnPublicResetPacket(packet);
316 } 318 }
317 CloseConnection(QUIC_PUBLIC_RESET, true); 319 CloseConnection(QUIC_PUBLIC_RESET, true);
318 320
319 DVLOG(1) << ENDPOINT << "Connection " << connection_id() 321 DVLOG(1) << ENDPOINT << "Connection " << connection_id()
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 612
611 last_stop_waiting_frames_.push_back(frame); 613 last_stop_waiting_frames_.push_back(frame);
612 return connected_; 614 return connected_;
613 } 615 }
614 616
615 bool QuicConnection::OnPingFrame(const QuicPingFrame& frame) { 617 bool QuicConnection::OnPingFrame(const QuicPingFrame& frame) {
616 DCHECK(connected_); 618 DCHECK(connected_);
617 if (debug_visitor_.get() != NULL) { 619 if (debug_visitor_.get() != NULL) {
618 debug_visitor_->OnPingFrame(frame); 620 debug_visitor_->OnPingFrame(frame);
619 } 621 }
622 last_ping_frames_.push_back(frame);
620 return true; 623 return true;
621 } 624 }
622 625
623 bool QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) { 626 bool QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) {
624 if (incoming_ack.largest_observed > packet_generator_.sequence_number()) { 627 if (incoming_ack.largest_observed > packet_generator_.sequence_number()) {
625 DLOG(ERROR) << ENDPOINT << "Peer's observed unsent packet:" 628 DLOG(ERROR) << ENDPOINT << "Peer's observed unsent packet:"
626 << incoming_ack.largest_observed << " vs " 629 << incoming_ack.largest_observed << " vs "
627 << packet_generator_.sequence_number(); 630 << packet_generator_.sequence_number();
628 // We got an error for data we have not sent. Error out. 631 // We got an error for data we have not sent. Error out.
629 return false; 632 return false;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 774
772 void QuicConnection::OnPacketComplete() { 775 void QuicConnection::OnPacketComplete() {
773 // Don't do anything if this packet closed the connection. 776 // Don't do anything if this packet closed the connection.
774 if (!connected_) { 777 if (!connected_) {
775 ClearLastFrames(); 778 ClearLastFrames();
776 return; 779 return;
777 } 780 }
778 781
779 DVLOG(1) << ENDPOINT << (last_packet_revived_ ? "Revived" : "Got") 782 DVLOG(1) << ENDPOINT << (last_packet_revived_ ? "Revived" : "Got")
780 << " packet " << last_header_.packet_sequence_number 783 << " packet " << last_header_.packet_sequence_number
781 << " with " << last_ack_frames_.size() << " acks, " 784 << " with " << last_stream_frames_.size()<< " stream frames "
785 << last_ack_frames_.size() << " acks, "
782 << last_congestion_frames_.size() << " congestions, " 786 << last_congestion_frames_.size() << " congestions, "
783 << last_stop_waiting_frames_.size() << " stop_waiting, " 787 << last_stop_waiting_frames_.size() << " stop_waiting, "
788 << last_rst_frames_.size() << " rsts, "
784 << last_goaway_frames_.size() << " goaways, " 789 << last_goaway_frames_.size() << " goaways, "
785 << last_window_update_frames_.size() << " window updates, " 790 << last_window_update_frames_.size() << " window updates, "
786 << last_blocked_frames_.size() << " blocked, " 791 << last_blocked_frames_.size() << " blocked, "
787 << last_rst_frames_.size() << " rsts, " 792 << last_ping_frames_.size() << " pings, "
788 << last_close_frames_.size() << " closes, " 793 << last_close_frames_.size() << " closes, "
789 << last_stream_frames_.size() 794 << "for " << last_header_.public_header.connection_id;
790 << " stream frames for "
791 << last_header_.public_header.connection_id;
792 795
793 // Call MaybeQueueAck() before recording the received packet, since we want 796 // Call MaybeQueueAck() before recording the received packet, since we want
794 // to trigger an ack if the newly received packet was previously missing. 797 // to trigger an ack if the newly received packet was previously missing.
795 MaybeQueueAck(); 798 MaybeQueueAck();
796 799
797 // Record received or revived packet to populate ack info correctly before 800 // Record received or revived packet to populate ack info correctly before
798 // processing stream frames, since the processing may result in a response 801 // processing stream frames, since the processing may result in a response
799 // packet with a bundled ack. 802 // packet with a bundled ack.
800 if (last_packet_revived_) { 803 if (last_packet_revived_) {
801 received_packet_manager_.RecordPacketRevived( 804 received_packet_manager_.RecordPacketRevived(
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 } 877 }
875 } 878 }
876 879
877 if (ack_queued_) { 880 if (ack_queued_) {
878 ack_alarm_->Cancel(); 881 ack_alarm_->Cancel();
879 } 882 }
880 } 883 }
881 884
882 void QuicConnection::ClearLastFrames() { 885 void QuicConnection::ClearLastFrames() {
883 last_stream_frames_.clear(); 886 last_stream_frames_.clear();
887 last_ack_frames_.clear();
888 last_congestion_frames_.clear();
889 last_stop_waiting_frames_.clear();
890 last_rst_frames_.clear();
884 last_goaway_frames_.clear(); 891 last_goaway_frames_.clear();
885 last_window_update_frames_.clear(); 892 last_window_update_frames_.clear();
886 last_blocked_frames_.clear(); 893 last_blocked_frames_.clear();
887 last_rst_frames_.clear(); 894 last_ping_frames_.clear();
888 last_ack_frames_.clear(); 895 last_close_frames_.clear();
889 last_stop_waiting_frames_.clear();
890 last_congestion_frames_.clear();
891 } 896 }
892 897
893 QuicAckFrame* QuicConnection::CreateAckFrame() { 898 QuicAckFrame* QuicConnection::CreateAckFrame() {
894 QuicAckFrame* outgoing_ack = new QuicAckFrame(); 899 QuicAckFrame* outgoing_ack = new QuicAckFrame();
895 received_packet_manager_.UpdateReceivedPacketInfo( 900 received_packet_manager_.UpdateReceivedPacketInfo(
896 outgoing_ack, clock_->ApproximateNow()); 901 outgoing_ack, clock_->ApproximateNow());
897 DVLOG(1) << ENDPOINT << "Creating ack frame: " << *outgoing_ack; 902 DVLOG(1) << ENDPOINT << "Creating ack frame: " << *outgoing_ack;
898 return outgoing_ack; 903 return outgoing_ack;
899 } 904 }
900 905
901 QuicCongestionFeedbackFrame* QuicConnection::CreateFeedbackFrame() { 906 QuicCongestionFeedbackFrame* QuicConnection::CreateFeedbackFrame() {
902 return new QuicCongestionFeedbackFrame(outgoing_congestion_feedback_); 907 return new QuicCongestionFeedbackFrame(outgoing_congestion_feedback_);
903 } 908 }
904 909
905 QuicStopWaitingFrame* QuicConnection::CreateStopWaitingFrame() { 910 QuicStopWaitingFrame* QuicConnection::CreateStopWaitingFrame() {
906 QuicStopWaitingFrame stop_waiting; 911 QuicStopWaitingFrame stop_waiting;
907 UpdateStopWaiting(&stop_waiting); 912 UpdateStopWaiting(&stop_waiting);
908 return new QuicStopWaitingFrame(stop_waiting); 913 return new QuicStopWaitingFrame(stop_waiting);
909 } 914 }
910 915
911 bool QuicConnection::ShouldLastPacketInstigateAck() const { 916 bool QuicConnection::ShouldLastPacketInstigateAck() const {
912 if (!last_stream_frames_.empty() || 917 if (!last_stream_frames_.empty() ||
913 !last_goaway_frames_.empty() || 918 !last_goaway_frames_.empty() ||
914 !last_rst_frames_.empty() || 919 !last_rst_frames_.empty() ||
915 !last_window_update_frames_.empty() || 920 !last_window_update_frames_.empty() ||
916 !last_blocked_frames_.empty()) { 921 !last_blocked_frames_.empty() ||
922 !last_ping_frames_.empty()) {
917 return true; 923 return true;
918 } 924 }
919 925
920 if (!last_ack_frames_.empty() && last_ack_frames_.back().is_truncated) { 926 if (!last_ack_frames_.empty() && last_ack_frames_.back().is_truncated) {
921 return true; 927 return true;
922 } 928 }
923 return false; 929 return false;
924 } 930 }
925 931
926 void QuicConnection::UpdateStopWaitingCount() { 932 void QuicConnection::UpdateStopWaitingCount() {
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 // If we changed the generator's batch state, restore original batch state. 1991 // If we changed the generator's batch state, restore original batch state.
1986 if (!already_in_batch_mode_) { 1992 if (!already_in_batch_mode_) {
1987 DVLOG(1) << "Leaving Batch Mode."; 1993 DVLOG(1) << "Leaving Batch Mode.";
1988 connection_->packet_generator_.FinishBatchOperations(); 1994 connection_->packet_generator_.FinishBatchOperations();
1989 } 1995 }
1990 DCHECK_EQ(already_in_batch_mode_, 1996 DCHECK_EQ(already_in_batch_mode_,
1991 connection_->packet_generator_.InBatchMode()); 1997 connection_->packet_generator_.InBatchMode());
1992 } 1998 }
1993 1999
1994 } // namespace net 2000 } // 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