Sync changes to rename onNewStream and CongestionController factory
MODIFY
quic/api/QuicSocket.h
quic/api/QuicSocket.h
@@ -44,7 +44,7 @@ class QuicSocket {
* Invoked when the peer creates a new bidirectional stream. The most
* common flow would be to set the ReadCallback from here
*/
- virtual void onNewStream(StreamId id) noexcept = 0;
+ virtual void onNewBidirectionalStream(StreamId id) noexcept = 0;
/**
* Invoked when the peer creates a new unidirectional stream. The most
@@ -445,7 +445,7 @@ class QuicSocket {
/**
* Usage:
* class Application {
- * void onNewStream(StreamId id) {
+ * void onNewBidirectionalStream(StreamId id) {
* socket_->setPeekCallback(id, this);
* }
*
@@ -844,7 +844,7 @@ class QuicSocket {
* A control stream outlives all the other streams in a connection, therefore,
* if the transport knows about it, can enable some optimizations.
* Applications should declare all their control streams after either calling
- * createStream() or receiving onNewStream()
+ * createStream() or receiving onNewBidirectionalStream()
*/
virtual folly::Optional<LocalErrorCode> setControlStream(StreamId id) = 0;
};

MODIFY
quic/api/QuicTransportBase.cpp
quic/api/QuicTransportBase.cpp
@@ -1247,7 +1247,7 @@ void QuicTransportBase::processCallbacksAfterNetworkData() {
for (const auto& stream : conn_->streamManager->newPeerStreams()) {
CHECK_NOTNULL(connCallback_);
if (isBidirectionalStream(stream)) {
- connCallback_->onNewStream(stream);
+ connCallback_->onNewBidirectionalStream(stream);
} else {
connCallback_->onNewUnidirectionalStream(stream);
}

MODIFY
quic/api/test/Mocks.h
quic/api/test/Mocks.h
@@ -101,7 +101,7 @@ class MockConnectionCallback : public QuicSocket::ConnectionCallback {
~MockConnectionCallback() override = default;
GMOCK_METHOD1_(, noexcept, , onFlowControlUpdate, void(StreamId));
- GMOCK_METHOD1_(, noexcept, , onNewStream, void(StreamId));
+ GMOCK_METHOD1_(, noexcept, , onNewBidirectionalStream, void(StreamId));
GMOCK_METHOD1_(, noexcept, , onNewUnidirectionalStream, void(StreamId));
GMOCK_METHOD2_(
,

MODIFY
quic/api/test/QuicTransportBaseTest.cpp
quic/api/test/QuicTransportBaseTest.cpp
@@ -690,7 +690,7 @@ TEST_F(QuicTransportImplTest, ReadCallbackForClientOutOfOrderStream) {
for (StreamId start = 0x00; start <= clientOutOfOrderStream;
start += kStreamIncrement) {
- EXPECT_CALL(connCallback, onNewStream(start))
+ EXPECT_CALL(connCallback, onNewBidirectionalStream(start))
.WillOnce(Invoke(
[&](StreamId id) { transport->setReadCallback(id, &streamRead); }));
}
@@ -770,15 +770,15 @@ TEST_F(QuicTransportImplTest, ReadCallbackDeleteTransport) {
transport.reset();
}
-TEST_F(QuicTransportImplTest, OnNewStreamCallback) {
+TEST_F(QuicTransportImplTest, onNewBidirectionalStreamCallback) {
auto readData = folly::IOBuf::copyBuffer("actual stream data");
StreamId stream2 = 0x00;
- EXPECT_CALL(connCallback, onNewStream(stream2));
+ EXPECT_CALL(connCallback, onNewBidirectionalStream(stream2));
transport->addDataToStream(stream2, StreamBuffer(readData->clone(), 0, true));
StreamId stream3 = 0x04;
- EXPECT_CALL(connCallback, onNewStream(stream3));
+ EXPECT_CALL(connCallback, onNewBidirectionalStream(stream3));
transport->addDataToStream(stream3, StreamBuffer(readData->clone(), 0, true));
StreamId uniStream3 = 0xa;
@@ -793,13 +793,13 @@ TEST_F(QuicTransportImplTest, OnNewStreamCallback) {
transport.reset();
}
-TEST_F(QuicTransportImplTest, OnNewStreamStreamOutOfOrder) {
+TEST_F(QuicTransportImplTest, onNewBidirectionalStreamStreamOutOfOrder) {
InSequence dummy;
auto readData = folly::IOBuf::copyBuffer("actual stream data");
StreamId biStream1 = 28;
StreamId uniStream1 = 30;
for (StreamId id = 0x00; id <= biStream1; id += kStreamIncrement) {
- EXPECT_CALL(connCallback, onNewStream(id));
+ EXPECT_CALL(connCallback, onNewBidirectionalStream(id));
}
for (StreamId id = 0x02; id <= uniStream1; id += kStreamIncrement) {
EXPECT_CALL(connCallback, onNewUnidirectionalStream(id));
@@ -813,7 +813,7 @@ TEST_F(QuicTransportImplTest, OnNewStreamStreamOutOfOrder) {
StreamId uniStream2 = 38;
for (StreamId id = biStream1 + kStreamIncrement; id <= biStream2;
id += kStreamIncrement) {
- EXPECT_CALL(connCallback, onNewStream(id));
+ EXPECT_CALL(connCallback, onNewBidirectionalStream(id));
}
for (StreamId id = uniStream1 + kStreamIncrement; id <= uniStream2;
id += kStreamIncrement) {
@@ -826,14 +826,14 @@ TEST_F(QuicTransportImplTest, OnNewStreamStreamOutOfOrder) {
transport.reset();
}
-TEST_F(QuicTransportImplTest, OnNewStreamSetReadCallback) {
+TEST_F(QuicTransportImplTest, onNewBidirectionalStreamSetReadCallback) {
InSequence dummy;
auto readData = folly::IOBuf::copyBuffer("actual stream data");
transport->addCryptoData(StreamBuffer(readData->clone(), 0, true));
MockReadCallback stream2Read;
StreamId stream2 = 0x00;
- EXPECT_CALL(connCallback, onNewStream(stream2))
+ EXPECT_CALL(connCallback, onNewBidirectionalStream(stream2))
.WillOnce(Invoke(
[&](StreamId id) { transport->setReadCallback(id, &stream2Read); }));
transport->addDataToStream(stream2, StreamBuffer(readData->clone(), 0, true));
@@ -842,7 +842,7 @@ TEST_F(QuicTransportImplTest, OnNewStreamSetReadCallback) {
MockReadCallback streamRead;
for (StreamId start = stream2 + kStreamIncrement; start <= stream3;
start += kStreamIncrement) {
- EXPECT_CALL(connCallback, onNewStream(start))
+ EXPECT_CALL(connCallback, onNewBidirectionalStream(start))
.WillOnce(Invoke(
[&](StreamId id) { transport->setReadCallback(id, &streamRead); }));
}

MODIFY
quic/client/test/QuicClientTransportTest.cpp
quic/client/test/QuicClientTransportTest.cpp
@@ -1287,7 +1287,7 @@ TEST_F(QuicClientTransportTest, SocketClosedDuringOnTransportReady) {
}
GMOCK_METHOD1_(, noexcept, , onFlowControlUpdate, void(StreamId));
- GMOCK_METHOD1_(, noexcept, , onNewStream, void(StreamId));
+ GMOCK_METHOD1_(, noexcept, , onNewBidirectionalStream, void(StreamId));
GMOCK_METHOD1_(, noexcept, , onNewUnidirectionalStream, void(StreamId));
GMOCK_METHOD2_(
,

MODIFY
quic/samples/echo/EchoClient.h
quic/samples/echo/EchoClient.h
@@ -54,7 +54,7 @@ class EchoClient : public quic::QuicSocket::ConnectionCallback,
<< ", error=" << toString(error);
}
- void onNewStream(quic::StreamId id) noexcept override {
+ void onNewBidirectionalStream(quic::StreamId id) noexcept override {
LOG(INFO) << "EchoClient: new bidirectional stream=" << id;
quicClient_->setReadCallback(id, this);
}

MODIFY
quic/samples/echo/EchoHandler.h
quic/samples/echo/EchoHandler.h
@@ -28,7 +28,7 @@ class EchoHandler : public quic::QuicSocket::ConnectionCallback,
sock = socket;
}
- void onNewStream(quic::StreamId id) noexcept override {
+ void onNewBidirectionalStream(quic::StreamId id) noexcept override {
LOG(INFO) << "Got bidirectional stream id=" << id;
sock->setReadCallback(id, this);
}

MODIFY
quic/server/QuicServer.cpp
quic/server/QuicServer.cpp
@@ -53,7 +53,8 @@ void QuicServer::setListenerSocketFactory(
void QuicServer::setCongestionControllerFactory(
std::shared_ptr<CongestionControllerFactory> ccFactory) {
CHECK(!initialized_)
- << " Congestion Control Factorty must be set before the server is initialized.";
+ << " Congestion Control Factorty must be set before the server is "
+ << "initialized.";
CHECK(ccFactory);
ccFactory_ = std::move(ccFactory);
}

MODIFY
quic/server/QuicServerWorker.cpp
quic/server/QuicServerWorker.cpp
@@ -362,9 +362,9 @@ void QuicServerWorker::dispatchPacketData(
trans->setRoutingCallback(this);
trans->setSupportedVersions(supportedVersions_);
trans->setOriginalPeerAddress(client);
+ trans->setCongestionControllerFactory(ccFactory_);
trans->setTransportSettings(transportSettings_);
trans->setConnectionIdAlgo(connIdAlgo_.get());
- trans->setCongestionControllerFactory(ccFactory_);
// parameters to create server chosen connection id
ServerConnectionIdParams serverConnIdParams(
hostId_, static_cast<uint8_t>(processId_), workerId_);

MODIFY
quic/server/test/QuicServerTransportTest.cpp
quic/server/test/QuicServerTransportTest.cpp
@@ -1414,7 +1414,7 @@ TEST_F(QuicServerTransportTest, RecvStopSendingBeforeStream) {
ASSERT_TRUE(builder.canBuildPacket());
writeFrame(std::move(stopSendingFrame), builder);
auto packet = std::move(builder).buildPacket();
- EXPECT_CALL(connCallback, onNewStream(streamId));
+ EXPECT_CALL(connCallback, onNewBidirectionalStream(streamId));
EXPECT_CALL(
connCallback, onStopSending(streamId, ApplicationErrorCode::STOPPING));
deliverData(packetToBuf(packet));

MODIFY
quic/server/test/QuicSocketTest.cpp
quic/server/test/QuicSocketTest.cpp
@@ -29,7 +29,7 @@ class QuicSocketTest : public Test {
void openStream(StreamId) {
EXPECT_CALL(*socket_, setReadCallback(3, &handler_));
- socket_->cb_->onNewStream(3);
+ socket_->cb_->onNewBidirectionalStream(3);
}
protected:

MODIFY
quic/state/QuicStreamManager.cpp
quic/state/QuicStreamManager.cpp
@@ -307,7 +307,7 @@ void QuicStreamManager::removeClosedStream(StreamId streamId) {
writableStreams_.erase(streamId);
blockedStreams_.erase(streamId);
deliverableStreams_.erase(streamId);
- flowControlUpdated_.erase(streamId);
+ windowUpdates_.erase(streamId);
auto itr = std::find(lossStreams_.begin(), lossStreams_.end(), streamId);
if (itr != lossStreams_.end()) {
lossStreams_.erase(itr);

MODIFY
quic/state/test/QuicStreamFunctionsTest.cpp
quic/state/test/QuicStreamFunctionsTest.cpp
@@ -1506,6 +1506,31 @@ TEST_F(QuicStreamFunctionsTest, HolbTimingReadDataCallsUpdateRL) {
EXPECT_EQ(1, stream->holbCount);
}
+TEST_F(QuicStreamFunctionsTest, RemovedClosedState) {
+ auto stream = conn.streamManager->createNextBidirectionalStream().value();
+ auto streamId = stream->id;
+ conn.streamManager->readableStreams().emplace(streamId);
+ conn.streamManager->peekableStreams().emplace(streamId);
+ conn.streamManager->addWritable(streamId);
+ conn.streamManager->queueBlocked(streamId, 0);
+ conn.streamManager->addDeliverable(streamId);
+ conn.streamManager->addLoss(streamId);
+ conn.streamManager->queueWindowUpdate(streamId);
+ conn.streamManager->addStopSending(
+ streamId, ApplicationErrorCode::HTTP_NO_ERROR);
+ stream->state = StreamStates::Closed{};
+ conn.streamManager->removeClosedStream(streamId);
+ EXPECT_FALSE(conn.streamManager->streamExists(streamId));
+ EXPECT_TRUE(conn.streamManager->readableStreams().empty());
+ EXPECT_TRUE(conn.streamManager->peekableStreams().empty());
+ EXPECT_FALSE(conn.streamManager->writableContains(streamId));
+ EXPECT_FALSE(conn.streamManager->hasBlocked());
+ EXPECT_FALSE(conn.streamManager->deliverableContains(streamId));
+ EXPECT_FALSE(conn.streamManager->hasLoss());
+ EXPECT_FALSE(conn.streamManager->pendingWindowUpdate(streamId));
+ EXPECT_TRUE(conn.streamManager->stopSendingStreams().empty());
+}
+
TEST_F(QuicServerStreamFunctionsTest, ServerGetClientQuicStream) {
StreamId clientStream = 0x10;
std::deque<StreamId> newStreams = {0x0, 0x4, 0x8, 0xc, 0x10};

Sync changes to rename onNewStream and CongestionController factory