Fix quicsession::willingandabletowrite to check connection level flow control for send control stream and qpack streams. protected by gfe2_reloadable_flag_quic_fix_willing_and_able_to_write.

PiperOrigin-RevId: 313853837
Change-Id: I3f2516d4ac11b8867ffafc45cbacb2b0ff0cbd9b
diff --git a/quic/core/quic_session.cc b/quic/core/quic_session.cc
index 52cbd2b..76869a3 100644
--- a/quic/core/quic_session.cc
+++ b/quic/core/quic_session.cc
@@ -663,11 +663,26 @@
       HasPendingHandshake()) {
     return true;
   }
-  return control_frame_manager_.WillingToWrite() ||
-         !streams_with_pending_retransmission_.empty() ||
-         write_blocked_streams_.HasWriteBlockedSpecialStream() ||
-         (!flow_controller_.IsBlocked() &&
-          write_blocked_streams_.HasWriteBlockedDataStreams());
+  if (control_frame_manager_.WillingToWrite() ||
+      !streams_with_pending_retransmission_.empty()) {
+    return true;
+  }
+  if (!GetQuicReloadableFlag(quic_fix_willing_and_able_to_write)) {
+    return write_blocked_streams_.HasWriteBlockedSpecialStream() ||
+           (!flow_controller_.IsBlocked() &&
+            write_blocked_streams_.HasWriteBlockedDataStreams());
+  }
+  QUIC_RELOADABLE_FLAG_COUNT(quic_fix_willing_and_able_to_write);
+  if (flow_controller_.IsBlocked()) {
+    if (VersionUsesHttp3(transport_version())) {
+      return false;
+    }
+    // Crypto and headers streams are not blocked by connection level flow
+    // control.
+    return write_blocked_streams_.HasWriteBlockedSpecialStream();
+  }
+  return write_blocked_streams_.HasWriteBlockedSpecialStream() ||
+         write_blocked_streams_.HasWriteBlockedDataStreams();
 }
 
 bool QuicSession::HasPendingHandshake() const {