gfe-relnote: Don't queue packets when closing a QUIC connection
This is a fix for crbug.com/979507
PiperOrigin-RevId: 256236902
Change-Id: Icc2a9050e138b83fb9409a0099ad983e2e2a2526
diff --git a/quic/core/quic_connection_test.cc b/quic/core/quic_connection_test.cc
index 3c5daa9..fdf366a 100644
--- a/quic/core/quic_connection_test.cc
+++ b/quic/core/quic_connection_test.cc
@@ -7551,6 +7551,34 @@
TestConnectionCloseQuicErrorCode(QUIC_PACKET_WRITE_ERROR);
}
+TEST_P(QuicConnectionTest, CloseConnectionOnQueuedWriteError) {
+ SetQuicReloadableFlag(quic_clear_queued_packets_on_connection_close, true);
+ // Regression test for crbug.com/979507.
+ //
+ // If we get a write error when writing queued packets, we should attempt to
+ // send a connection close packet, but if sending that fails, it shouldn't get
+ // queued.
+
+ // Queue a packet to write.
+ BlockOnNextWrite();
+ connection_.SendStreamDataWithString(3, "foo", 0, NO_FIN);
+ EXPECT_EQ(1u, connection_.NumQueuedPackets());
+
+ // Configure writer to always fail.
+ AlwaysGetPacketTooLarge();
+
+ // Expect that we attempt to close the connection exactly once.
+ EXPECT_CALL(visitor_, OnConnectionClosed(_, ConnectionCloseSource::FROM_SELF))
+ .Times(1);
+
+ // Unblock the writes and actually send.
+ writer_->SetWritable();
+ connection_.OnCanWrite();
+ EXPECT_EQ(0u, connection_.NumQueuedPackets());
+
+ TestConnectionCloseQuicErrorCode(QUIC_PACKET_WRITE_ERROR);
+}
+
// Verify that if connection has no outstanding data, it notifies the send
// algorithm after the write.
TEST_P(QuicConnectionTest, SendDataAndBecomeApplicationLimited) {