Check if CID is missing in QuicConnection::WriteIfNotBlocked.

Without this change, write unexpectedly blocked QUIC BUG can be triggered when:
(1) Multiple UDP packets are processed for the same session in the same Epoll loop.
(2) Early packets schedule a send alarm.
(3) Later packets made destination CID unavailable.

Protected by FLAGS_quic_reloadable_flag_quic_write_is_blocked_when_cid_is_missing.

PiperOrigin-RevId: 540964630
diff --git a/quiche/quic/core/quic_connection.cc b/quiche/quic/core/quic_connection.cc
index 22174b9..218c418 100644
--- a/quiche/quic/core/quic_connection.cc
+++ b/quiche/quic/core/quic_connection.cc
@@ -2759,6 +2759,15 @@
         << ENDPOINT << "Tried to write in mid of packet processing";
     return;
   }
+  if (GetQuicReloadableFlag(quic_write_is_blocked_when_cid_is_missing)) {
+    QUIC_RELOADABLE_FLAG_COUNT_N(quic_write_is_blocked_when_cid_is_missing, 1,
+                                 2);
+    if (IsMissingDestinationConnectionID()) {
+      QUIC_RELOADABLE_FLAG_COUNT_N(quic_write_is_blocked_when_cid_is_missing, 2,
+                                   2);
+      return;
+    }
+  }
   if (!HandleWriteBlocked()) {
     OnCanWrite();
   }
diff --git a/quiche/quic/core/quic_flags_list.h b/quiche/quic/core/quic_flags_list.h
index d28cb38..4dee0a7 100644
--- a/quiche/quic/core/quic_flags_list.h
+++ b/quiche/quic/core/quic_flags_list.h
@@ -29,6 +29,8 @@
 QUIC_FLAG(quic_reloadable_flag_quic_allow_client_enabled_bbr_v2, true)
 // If true, an endpoint does not detect path degrading or blackholing until handshake gets confirmed.
 QUIC_FLAG(quic_reloadable_flag_quic_no_path_degrading_before_handshake_confirmed, true)
+// If true, consider write blocked when destination CID is required but missing on the default path.
+QUIC_FLAG(quic_reloadable_flag_quic_write_is_blocked_when_cid_is_missing, false)
 // If true, default-enable 5RTO blachole detection.
 QUIC_FLAG(quic_reloadable_flag_quic_default_enable_5rto_blackhole_detection2, true)
 // If true, disable QUIC version Q046.