In quic, stop blackhole detection if timer based loss detection removes all packets from in flight but no retransmission can be sent (e.g., write blocked, message frame, etc). protected by existing gfe2_reloadable_flag_quic_default_enable_5rto_blackhole_detection2.
Also add QUIC_BUGs to make sure there are bytes in flight when arming blackhole detection and when the blackhole is detected.
PiperOrigin-RevId: 315728450
Change-Id: I017bc77a95b88da460676de21cc40199d4b129c8
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index 7b1b9af..18389f0 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -2695,6 +2695,11 @@
const bool in_flight = sent_packet_manager_.OnPacketSent(
packet, packet_send_time, packet->transmission_type,
IsRetransmittable(*packet));
+ QUIC_BUG_IF(default_enable_5rto_blackhole_detection_ &&
+ blackhole_detector_.IsDetectionInProgress() &&
+ !sent_packet_manager_.HasInFlightPackets())
+ << ENDPOINT
+ << "Trying to start blackhole detection without no bytes in flight";
if (in_flight || !retransmission_alarm_->IsSet()) {
SetRetransmissionAlarm();
@@ -2985,6 +2990,13 @@
debug_visitor_->OnNPacketNumbersSkipped(num_packet_numbers_to_skip);
}
}
+ if (default_enable_5rto_blackhole_detection_ &&
+ !sent_packet_manager_.HasInFlightPackets() &&
+ blackhole_detector_.IsDetectionInProgress()) {
+ // Stop detection in quiescence.
+ DCHECK_EQ(QuicSentPacketManager::LOSS_MODE, retransmission_mode);
+ blackhole_detector_.StopDetection();
+ }
WriteIfNotBlocked();
// A write failure can result in the connection being closed, don't attempt to
@@ -4361,6 +4373,11 @@
// Stop detections in quiecense.
blackhole_detector_.StopDetection();
}
+ QUIC_BUG_IF(default_enable_5rto_blackhole_detection_ &&
+ blackhole_detector_.IsDetectionInProgress() &&
+ !sent_packet_manager_.HasInFlightPackets())
+ << ENDPOINT
+ << "Trying to start blackhole detection without no bytes in flight";
}
QuicPacketNumber QuicConnection::GetLargestReceivedPacketWithAck() const {
@@ -4474,6 +4491,11 @@
}
void QuicConnection::OnBlackholeDetected() {
+ QUIC_BUG_IF(default_enable_5rto_blackhole_detection_ &&
+ !sent_packet_manager_.HasInFlightPackets())
+ << ENDPOINT
+ << "Closing connection because of blackhole, but there is no bytes in "
+ "flight";
CloseConnection(QUIC_TOO_MANY_RTOS, "Network blackhole detected.",
ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
}