Add directionality check for OnCanCreateNewOutgoingStream(). QuicSimpleServerSession only creates unidirectional push streams, and grpc sessions only create bidirectional streams. gfe-relnote: Change is not used in prod, not protected. PiperOrigin-RevId: 258999547 Change-Id: Id2334dba63dc94179f8403ef9207799f2a147e3a
diff --git a/quic/core/quic_session.cc b/quic/core/quic_session.cc index e5650a9..221d75e 100644 --- a/quic/core/quic_session.cc +++ b/quic/core/quic_session.cc
@@ -10,6 +10,7 @@ #include "net/third_party/quiche/src/quic/core/quic_connection.h" #include "net/third_party/quiche/src/quic/core/quic_flow_controller.h" +#include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" #include "net/third_party/quiche/src/quic/core/quic_versions.h" #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" @@ -811,6 +812,7 @@ ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); return; } + StreamType type = stream->type(); // Tell the stream that a RST has been sent. if (locally_reset) { @@ -870,9 +872,7 @@ !VersionHasIetfQuicFrames(connection_->transport_version())) { // Streams that first became draining already called OnCanCreate... // This covers the case where the stream went directly to being closed. - // called with unidirectional false because this is for Google QUIC, which - // supports only bidirectional streams. - OnCanCreateNewOutgoingStream(false); + OnCanCreateNewOutgoingStream(type != BIDIRECTIONAL); } } @@ -1274,14 +1274,15 @@ if (!IsIncomingStream(stream_id)) { // Inform application that a stream is available. if (VersionHasIetfQuicFrames(connection_->transport_version())) { - if (QuicUtils::IsBidirectionalStreamId(stream_id)) { - OnCanCreateNewOutgoingStream(false); - } else { - OnCanCreateNewOutgoingStream(true); - } + OnCanCreateNewOutgoingStream( + !QuicUtils::IsBidirectionalStreamId(stream_id)); } else { - // Google QUIC has only bidirectional streams. - OnCanCreateNewOutgoingStream(false); + QuicStream* stream = GetStream(stream_id); + if (!stream) { + QUIC_BUG << "Stream doesn't exist when draining."; + return; + } + OnCanCreateNewOutgoingStream(stream->type() != BIDIRECTIONAL); } } }
diff --git a/quic/tools/quic_simple_server_session.cc b/quic/tools/quic_simple_server_session.cc index ad59527..2e98cdd 100644 --- a/quic/tools/quic_simple_server_session.cc +++ b/quic/tools/quic_simple_server_session.cc
@@ -227,7 +227,9 @@ } void QuicSimpleServerSession::OnCanCreateNewOutgoingStream( - bool /*unidirectional*/) { - HandlePromisedPushRequests(); + bool unidirectional) { + if (unidirectional) { + HandlePromisedPushRequests(); + } } } // namespace quic