diff --git a/quic/api/QuicSocket.h b/quic/api/QuicSocket.h index 3a820d032..8f0e57f36 100644 --- a/quic/api/QuicSocket.h +++ b/quic/api/QuicSocket.h @@ -132,10 +132,11 @@ class QuicSocket { StreamGroupId) noexcept {} /** - * Invoked when a given stream has been closed and its state reaped by - * the transport. After this point no operations can be done on the stream. + * Invoked when a given stream has been closed and its state is about to + * be reaped by the transport. This is the last chance to do any final + * state querying operations on the stream. */ - virtual void onStreamStateReaped(StreamId) noexcept {} + virtual void onStreamPreReaped(StreamId) noexcept {} /** * Invoked when a stream receives a StopSending frame from a peer. diff --git a/quic/api/QuicTransportBase.cpp b/quic/api/QuicTransportBase.cpp index ef2d195b5..edb31234b 100644 --- a/quic/api/QuicTransportBase.cpp +++ b/quic/api/QuicTransportBase.cpp @@ -2610,10 +2610,10 @@ void QuicTransportBase::checkForClosedStream() { conn_->qLogger->addTransportStateUpdate( getClosingStream(folly::to(*itr))); } - conn_->streamManager->removeClosedStream(*itr); if (connCallback_) { - connCallback_->onStreamStateReaped(*itr); + connCallback_->onStreamPreReaped(*itr); } + conn_->streamManager->removeClosedStream(*itr); maybeSendStreamLimitUpdates(*conn_); if (readCbIt != readCallbacks_.end()) { readCallbacks_.erase(readCbIt); diff --git a/quic/api/test/Mocks.h b/quic/api/test/Mocks.h index 2647e7f83..2942b2ff1 100644 --- a/quic/api/test/Mocks.h +++ b/quic/api/test/Mocks.h @@ -123,7 +123,7 @@ class MockConnectionCallback : public QuicSocket::ConnectionCallback { onNewUnidirectionalStreamInGroup, (StreamId, StreamGroupId), (noexcept)); - MOCK_METHOD((void), onStreamStateReaped, (StreamId), (noexcept)); + MOCK_METHOD((void), onStreamPreReaped, (StreamId), (noexcept)); MOCK_METHOD( (void), onStopSending, diff --git a/quic/api/test/QuicTransportBaseTest.cpp b/quic/api/test/QuicTransportBaseTest.cpp index 3579d7391..4c52ba069 100644 --- a/quic/api/test/QuicTransportBaseTest.cpp +++ b/quic/api/test/QuicTransportBaseTest.cpp @@ -1743,7 +1743,7 @@ TEST_P(QuicTransportImplTestBase, CloseStreamAfterReadError) { transport->closeStream(stream1); EXPECT_CALL(readCb1, readError(stream1, IsError(LocalErrorCode::NO_ERROR))); - EXPECT_CALL(connCallback, onStreamStateReaped(stream1)); + EXPECT_CALL(connCallback, onStreamPreReaped(stream1)); transport->driveReadCallbacks(); EXPECT_FALSE(transport->transportConn->streamManager->streamExists(stream1));