Skip to content

Commit

Permalink
fix onBidirectionalStreamsAvailable
Browse files Browse the repository at this point in the history
Summary:
fixes the arg passed to the ::onBidirectionalStreamsAvailable callback

#facebook:
i accidentally introduced a bad operator precedence bug in a refactor; this fixes that and the unit test

luckily HQSession doesn't consume the argument passed to the callback

Reviewed By: knekritz

Differential Revision: D62765762

fbshipit-source-id: 7ae206d5036fc744485736f92fd366ce99103d58
  • Loading branch information
hanidamlaj authored and facebook-github-bot committed Sep 17, 2024
1 parent b009969 commit 07f2980
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions quic/api/QuicTransportBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,15 +1064,17 @@ void QuicTransportBase::invokeStreamsAvailableCallbacks() {
if (conn_->streamManager->consumeMaxLocalBidirectionalStreamIdIncreased()) {
// check in case new streams were created in preceding callbacks
// and max is already reached
if (auto numStreams = getNumOpenableBidirectionalStreams() > 0) {
connCallback_->onBidirectionalStreamsAvailable(numStreams);
auto numOpenableStreams = getNumOpenableBidirectionalStreams();
if (numOpenableStreams > 0) {
connCallback_->onBidirectionalStreamsAvailable(numOpenableStreams);
}
}
if (conn_->streamManager->consumeMaxLocalUnidirectionalStreamIdIncreased()) {
// check in case new streams were created in preceding callbacks
// and max is already reached
if (auto numStreams = getNumOpenableUnidirectionalStreams() > 0) {
connCallback_->onUnidirectionalStreamsAvailable(numStreams);
auto numOpenableStreams = getNumOpenableUnidirectionalStreams();
if (numOpenableStreams > 0) {
connCallback_->onUnidirectionalStreamsAvailable(numOpenableStreams);
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions quic/api/test/QuicTransportBaseTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1636,13 +1636,15 @@ TEST_P(QuicTransportImplTestBase, onBidiStreamsAvailableCallback) {

EXPECT_CALL(connCallback, onBidirectionalStreamsAvailable(_))
.WillOnce(Invoke([](uint64_t numAvailableStreams) {
EXPECT_EQ(numAvailableStreams, 1);
EXPECT_EQ(numAvailableStreams, 10);
}));
transport->addMaxStreamsFrame(MaxStreamsFrame(1, /*isBidirectionalIn=*/true));
EXPECT_EQ(transport->getNumOpenableBidirectionalStreams(), 1);
transport->addMaxStreamsFrame(
MaxStreamsFrame(10, /*isBidirectionalIn=*/true));
EXPECT_EQ(transport->getNumOpenableBidirectionalStreams(), 10);

// same value max streams frame doesn't trigger callback
transport->addMaxStreamsFrame(MaxStreamsFrame(1, /*isBidirectionalIn=*/true));
transport->addMaxStreamsFrame(
MaxStreamsFrame(10, /*isBidirectionalIn=*/true));
}

TEST_P(QuicTransportImplTestBase, onBidiStreamsAvailableCallbackAfterExausted) {
Expand Down

0 comments on commit 07f2980

Please sign in to comment.