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 <errno.h> | 7 #include <errno.h> |
8 #include <memory> | 8 #include <memory> |
9 #include <ostream> | 9 #include <ostream> |
10 #include <utility> | 10 #include <utility> |
(...skipping 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2035 clock_.AdvanceTime(DefaultRetransmissionTime()); | 2035 clock_.AdvanceTime(DefaultRetransmissionTime()); |
2036 connection_.GetRetransmissionAlarm()->Fire(); | 2036 connection_.GetRetransmissionAlarm()->Fire(); |
2037 EXPECT_EQ(1u, writer_->frame_count()); | 2037 EXPECT_EQ(1u, writer_->frame_count()); |
2038 EXPECT_EQ(1u, writer_->rst_stream_frames().size()); | 2038 EXPECT_EQ(1u, writer_->rst_stream_frames().size()); |
2039 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id); | 2039 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id); |
2040 } | 2040 } |
2041 | 2041 |
2042 // Ensure that if the only data in flight is non-retransmittable, the | 2042 // Ensure that if the only data in flight is non-retransmittable, the |
2043 // retransmission alarm is not set. | 2043 // retransmission alarm is not set. |
2044 TEST_P(QuicConnectionTest, CancelRetransmissionAlarmAfterResetStream) { | 2044 TEST_P(QuicConnectionTest, CancelRetransmissionAlarmAfterResetStream) { |
2045 FLAGS_quic_reloadable_flag_quic_more_conservative_retransmission_alarm = true; | |
2046 QuicStreamId stream_id = 2; | 2045 QuicStreamId stream_id = 2; |
2047 QuicPacketNumber last_data_packet; | 2046 QuicPacketNumber last_data_packet; |
2048 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_data_packet); | 2047 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_data_packet); |
2049 | 2048 |
2050 // Cancel the stream. | 2049 // Cancel the stream. |
2051 const QuicPacketNumber rst_packet = last_data_packet + 1; | 2050 const QuicPacketNumber rst_packet = last_data_packet + 1; |
2052 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, rst_packet, _, _)).Times(1); | 2051 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, rst_packet, _, _)).Times(1); |
2053 connection_.SendRstStream(stream_id, QUIC_ERROR_PROCESSING_STREAM, 14); | 2052 connection_.SendRstStream(stream_id, QUIC_ERROR_PROCESSING_STREAM, 14); |
2054 | 2053 |
2055 // Ack the RST_STREAM frame (since it's retransmittable), but not the data | 2054 // Ack the RST_STREAM frame (since it's retransmittable), but not the data |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2280 | 2279 |
2281 // Ack the sent packet before the callback returns, which happens in | 2280 // Ack the sent packet before the callback returns, which happens in |
2282 // rare circumstances with write blocked sockets. | 2281 // rare circumstances with write blocked sockets. |
2283 QuicAckFrame ack = InitAckFrame(1); | 2282 QuicAckFrame ack = InitAckFrame(1); |
2284 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _, _)); | 2283 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _, _)); |
2285 ProcessAckPacket(&ack); | 2284 ProcessAckPacket(&ack); |
2286 | 2285 |
2287 writer_->SetWritable(); | 2286 writer_->SetWritable(); |
2288 connection_.OnCanWrite(); | 2287 connection_.OnCanWrite(); |
2289 // There is now a pending packet, but with no retransmittable frames. | 2288 // There is now a pending packet, but with no retransmittable frames. |
2290 EXPECT_EQ( | 2289 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
2291 FLAGS_quic_reloadable_flag_quic_more_conservative_retransmission_alarm, | |
2292 !connection_.GetRetransmissionAlarm()->IsSet()); | |
2293 EXPECT_FALSE(QuicConnectionPeer::HasRetransmittableFrames(&connection_, | 2290 EXPECT_FALSE(QuicConnectionPeer::HasRetransmittableFrames(&connection_, |
2294 ack.path_id, 2)); | 2291 ack.path_id, 2)); |
2295 } | 2292 } |
2296 | 2293 |
2297 TEST_P(QuicConnectionTest, AlarmsWhenWriteBlocked) { | 2294 TEST_P(QuicConnectionTest, AlarmsWhenWriteBlocked) { |
2298 // Block the connection. | 2295 // Block the connection. |
2299 BlockOnNextWrite(); | 2296 BlockOnNextWrite(); |
2300 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); | 2297 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
2301 EXPECT_EQ(1u, writer_->packets_write_attempts()); | 2298 EXPECT_EQ(1u, writer_->packets_write_attempts()); |
2302 EXPECT_TRUE(writer_->IsWriteBlocked()); | 2299 EXPECT_TRUE(writer_->IsWriteBlocked()); |
(...skipping 2812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5115 error_details, ConnectionCloseSource::FROM_PEER)); | 5112 error_details, ConnectionCloseSource::FROM_PEER)); |
5116 connection_.set_perspective(Perspective::IS_CLIENT); | 5113 connection_.set_perspective(Perspective::IS_CLIENT); |
5117 connection_.CloseConnection(QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, | 5114 connection_.CloseConnection(QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, |
5118 error_details, | 5115 error_details, |
5119 ConnectionCloseBehavior::SILENT_CLOSE); | 5116 ConnectionCloseBehavior::SILENT_CLOSE); |
5120 } | 5117 } |
5121 | 5118 |
5122 } // namespace | 5119 } // namespace |
5123 } // namespace test | 5120 } // namespace test |
5124 } // namespace net | 5121 } // namespace net |
OLD | NEW |