Remove redundant stream finding code when STOP_SENDING frame is received. QuicSession::OnStopSending() already finds the stream and does staticness checks. We can simplify QuicSession::SendRstStreamInner() by moving the stream book keeping to OnStopSending(). gfe-relnote: protected by disabled v99 flag. PiperOrigin-RevId: 278745064 Change-Id: I3734cff264fdadd58d3dfe50b418fd4c76bd19ce
diff --git a/quic/core/quic_session.cc b/quic/core/quic_session.cc index c16b723..2761e61 100644 --- a/quic/core/quic_session.cc +++ b/quic/core/quic_session.cc
@@ -272,6 +272,8 @@ static_cast<quic::QuicRstStreamErrorCode>(frame.application_error_code), stream->stream_bytes_written(), /*close_write_side_only=*/true); + stream->set_rst_sent(true); + stream->CloseWriteSide(); } void QuicSession::PendingStreamOnRstStream(const QuicRstStreamFrame& frame) { @@ -715,26 +717,6 @@ if (!close_write_side_only) { CloseStreamInner(id, true); - return; - } - DCHECK(VersionHasIetfQuicFrames(transport_version())); - - StreamMap::iterator it = stream_map_.find(id); - if (it != stream_map_.end()) { - if (it->second->is_static()) { - QUIC_DVLOG(1) << ENDPOINT - << "Try to send rst for a static stream, id: " << id - << " Closing connection"; - connection()->CloseConnection( - QUIC_INVALID_STREAM_ID, "Sending rst for a static stream", - ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); - return; - } - QuicStream* stream = it->second.get(); - if (stream) { - stream->set_rst_sent(true); - stream->CloseWriteSide(); - } } }
diff --git a/quic/core/quic_session.h b/quic/core/quic_session.h index 6a6a4b2..c4f2d98 100644 --- a/quic/core/quic_session.h +++ b/quic/core/quic_session.h
@@ -209,7 +209,9 @@ // the peer. Returns true if |frame| is consumed, false otherwise. virtual bool WriteControlFrame(const QuicFrame& frame); - // Called by streams when they want to close the stream in both directions. + // Close the stream in both directions. + // TODO(renjietang): rename this method as it sends both RST_STREAM and + // STOP_SENDING in IETF QUIC. virtual void SendRstStream(QuicStreamId id, QuicRstStreamErrorCode error, QuicStreamOffset bytes_written);
diff --git a/quic/core/quic_stream_test.cc b/quic/core/quic_stream_test.cc index 74fbcf2..c82b4d0 100644 --- a/quic/core/quic_stream_test.cc +++ b/quic/core/quic_stream_test.cc
@@ -1577,27 +1577,6 @@ } } -// Test that receiving a STOP_SENDING just closes the write side of the stream. -// If not V99, the test is a noop (no STOP_SENDING in Google QUIC). -TEST_P(QuicStreamTest, OnStopSendingReadOrReadWrite) { - Initialize(); - if (!VersionHasIetfQuicFrames(connection_->transport_version())) { - return; - } - - EXPECT_FALSE(stream_->write_side_closed()); - EXPECT_FALSE(QuicStreamPeer::read_side_closed(stream_)); - - // Simulate receipt of a STOP_SENDING. - stream_->OnStopSending(123); - - // Should close just the read side. - EXPECT_FALSE(QuicStreamPeer::read_side_closed(stream_)); - // TODO(b/142425843): Currently no action is taken upon receiving stop - // sending. Need to figure out what to do and turn on this expectation. - // EXPECT_TRUE(stream_->write_side_closed()); -} - // SendOnlyRstStream must only send a RESET_STREAM (no bundled STOP_SENDING). TEST_P(QuicStreamTest, SendOnlyRstStream) { Initialize(); @@ -1615,10 +1594,6 @@ QUIC_BAD_APPLICATION_PAYLOAD, stream_->stream_bytes_written(), /*close_write_side_only=*/true); - - // ResetStreamOnly should just close the write side. - EXPECT_FALSE(QuicStreamPeer::read_side_closed(stream_)); - EXPECT_TRUE(stream_->write_side_closed()); } TEST_P(QuicStreamTest, WindowUpdateForReadOnlyStream) {