1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-08-06 22:22:38 +03:00

Remove superfluous looping through all resets

Summary: There's no need to loop through all the streams if we're just resetting one.

Reviewed By: hanidamlaj

Differential Revision: D67304631

fbshipit-source-id: 4817459ca7d1c1fd906b7640a0089c1c52e6e485
This commit is contained in:
Aman Sharma
2024-12-17 22:29:50 -08:00
committed by Facebook GitHub Bot
parent 4d0ba520f0
commit 683b982c15
2 changed files with 24 additions and 6 deletions

View File

@@ -430,12 +430,7 @@ folly::Expected<folly::Unit, LocalErrorCode> QuicTransportBaseLite::resetStream(
// Invoke state machine // Invoke state machine
sendRstSMHandler(*stream, errorCode); sendRstSMHandler(*stream, errorCode);
for (auto pendingResetIt = conn_->pendingEvents.resets.begin(); cancelByteEventCallbacksForStream(id);
closeState_ == CloseState::OPEN &&
pendingResetIt != conn_->pendingEvents.resets.end();
pendingResetIt++) {
cancelByteEventCallbacksForStream(pendingResetIt->first);
}
pendingWriteCallbacks_.erase(id); pendingWriteCallbacks_.erase(id);
QUIC_STATS(conn_->statsCallback, onQuicStreamReset, errorCode); QUIC_STATS(conn_->statsCallback, onQuicStreamReset, errorCode);
} catch (const QuicTransportException& ex) { } catch (const QuicTransportException& ex) {

View File

@@ -3091,6 +3091,29 @@ TEST_P(QuicTransportImplTestBase, TestGracefulCloseWithNoActiveStream) {
.hasError()); .hasError());
} }
TEST_P(QuicTransportImplTestBase, TestResetRemovesDeliveryCb) {
auto stream1 = transport->createBidirectionalStream().value();
auto stream2 = transport->createBidirectionalStream().value();
NiceMock<MockDeliveryCallback> deliveryCb1;
NiceMock<MockDeliveryCallback> deliveryCb2;
EXPECT_CALL(*socketPtr, write(_, _, _))
.WillRepeatedly(SetErrnoAndReturn(EAGAIN, -1));
transport->writeChain(stream1, IOBuf::copyBuffer("hello"), true, nullptr);
transport->writeChain(stream2, IOBuf::copyBuffer("hello"), true, nullptr);
EXPECT_FALSE(
transport->registerDeliveryCallback(stream1, 2, &deliveryCb1).hasError());
EXPECT_FALSE(
transport->registerDeliveryCallback(stream2, 2, &deliveryCb2).hasError());
EXPECT_EQ(transport->getNumByteEventCallbacksForStream(stream1), 1);
EXPECT_EQ(transport->getNumByteEventCallbacksForStream(stream2), 1);
EXPECT_FALSE(
transport->resetStream(stream1, GenericApplicationErrorCode::UNKNOWN)
.hasError());
EXPECT_EQ(transport->getNumByteEventCallbacksForStream(stream1), 0);
EXPECT_EQ(transport->getNumByteEventCallbacksForStream(stream2), 1);
transport->close(none);
}
TEST_P(QuicTransportImplTestBase, TestImmediateClose) { TEST_P(QuicTransportImplTestBase, TestImmediateClose) {
auto stream = transport->createBidirectionalStream().value(); auto stream = transport->createBidirectionalStream().value();
auto stream2 = transport->createBidirectionalStream().value(); auto stream2 = transport->createBidirectionalStream().value();