1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-11-09 10:00:57 +03:00

Add a useSplitConnectionCallbacks to mvfst

Summary:
This change just adds a (currently no-op) flag that will be used in diffs up the stack.

The idea here is that I'll add split QUIC connection callback interfaces that will live side by side with existing single monolithic callback for now. We will experiment with split callbacks on small scale to see that there is no regressions and then will phase out the old callback gradually.

This flag is to control which callback(s) to use.

Reviewed By: mjoras

Differential Revision: D30399667

fbshipit-source-id: 8fc4e4a005e93cf6d48a987f49edee33b90dbbf1
This commit is contained in:
Konstantin Tsoy
2021-08-31 18:23:38 -07:00
committed by Facebook GitHub Bot
parent 6659296aed
commit 21ea1990ab
6 changed files with 38 additions and 14 deletions

View File

@@ -29,7 +29,8 @@ namespace quic {
QuicTransportBase::QuicTransportBase( QuicTransportBase::QuicTransportBase(
folly::EventBase* evb, folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket) std::unique_ptr<folly::AsyncUDPSocket> socket,
bool useSplitConnectionCallbacks)
: evb_(evb), : evb_(evb),
socket_(std::move(socket)), socket_(std::move(socket)),
lossTimeout_(this), lossTimeout_(this),
@@ -52,7 +53,8 @@ QuicTransportBase::QuicTransportBase(
writeLooper_(new FunctionLooper( writeLooper_(new FunctionLooper(
evb, evb,
[this](bool fromTimer) { pacedWriteDataToSocket(fromTimer); }, [this](bool fromTimer) { pacedWriteDataToSocket(fromTimer); },
LooperType::WriteLooper)) { LooperType::WriteLooper)),
useSplitConnectionCallbacks_(useSplitConnectionCallbacks) {
writeLooper_->setPacingFunction([this]() -> auto { writeLooper_->setPacingFunction([this]() -> auto {
if (isConnectionPaced(*conn_)) { if (isConnectionPaced(*conn_)) {
return conn_->pacer->getTimeUntilNextWrite(); return conn_->pacer->getTimeUntilNextWrite();

View File

@@ -39,7 +39,8 @@ class QuicTransportBase : public QuicSocket {
public: public:
QuicTransportBase( QuicTransportBase(
folly::EventBase* evb, folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket); std::unique_ptr<folly::AsyncUDPSocket> socket,
bool useSplitConnectionCallbacks = false);
~QuicTransportBase() override; ~QuicTransportBase() override;
@@ -875,6 +876,11 @@ class QuicTransportBase : public QuicSocket {
std::shared_ptr<ObserverVec> observers_{std::make_shared<ObserverVec>()}; std::shared_ptr<ObserverVec> observers_{std::make_shared<ObserverVec>()};
uint64_t qlogRefcnt_{0}; uint64_t qlogRefcnt_{0};
// Temp flag controlling which connection callbacks to use - old single
// callback object or two new split callback objects. Will be removed out once
// mvfst is switched to the new split callbacks eventually.
bool useSplitConnectionCallbacks_{false};
}; };
std::ostream& operator<<(std::ostream& os, const QuicTransportBase& qt); std::ostream& operator<<(std::ostream& os, const QuicTransportBase& qt);

View File

@@ -39,12 +39,14 @@ QuicClientTransport::QuicClientTransport(
std::unique_ptr<folly::AsyncUDPSocket> socket, std::unique_ptr<folly::AsyncUDPSocket> socket,
std::shared_ptr<ClientHandshakeFactory> handshakeFactory, std::shared_ptr<ClientHandshakeFactory> handshakeFactory,
size_t connectionIdSize, size_t connectionIdSize,
PacketNum startingPacketNum) PacketNum startingPacketNum,
bool useSplitConnectionCallbacks)
: QuicClientTransport( : QuicClientTransport(
evb, evb,
std::move(socket), std::move(socket),
std::move(handshakeFactory), std::move(handshakeFactory),
connectionIdSize) { connectionIdSize,
useSplitConnectionCallbacks) {
conn_->ackStates = AckStates(startingPacketNum); conn_->ackStates = AckStates(startingPacketNum);
} }
@@ -52,8 +54,9 @@ QuicClientTransport::QuicClientTransport(
folly::EventBase* evb, folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket, std::unique_ptr<folly::AsyncUDPSocket> socket,
std::shared_ptr<ClientHandshakeFactory> handshakeFactory, std::shared_ptr<ClientHandshakeFactory> handshakeFactory,
size_t connectionIdSize) size_t connectionIdSize,
: QuicTransportBase(evb, std::move(socket)), bool useSplitConnectionCallbacks)
: QuicTransportBase(evb, std::move(socket), useSplitConnectionCallbacks),
happyEyeballsConnAttemptDelayTimeout_(this) { happyEyeballsConnAttemptDelayTimeout_(this) {
DCHECK(handshakeFactory); DCHECK(handshakeFactory);
auto tempConn = auto tempConn =

View File

@@ -32,7 +32,8 @@ class QuicClientTransport
folly::EventBase* evb, folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket, std::unique_ptr<folly::AsyncUDPSocket> socket,
std::shared_ptr<ClientHandshakeFactory> handshakeFactory, std::shared_ptr<ClientHandshakeFactory> handshakeFactory,
size_t connectionIdSize = 0); size_t connectionIdSize = 0,
bool useSplitConnectionCallbacks = false);
// Testing only API: // Testing only API:
QuicClientTransport( QuicClientTransport(
@@ -40,7 +41,8 @@ class QuicClientTransport
std::unique_ptr<folly::AsyncUDPSocket> socket, std::unique_ptr<folly::AsyncUDPSocket> socket,
std::shared_ptr<ClientHandshakeFactory> handshakeFactory, std::shared_ptr<ClientHandshakeFactory> handshakeFactory,
size_t connectionIdSize, size_t connectionIdSize,
PacketNum startingPacketNum); PacketNum startingPacketNum,
bool useSplitConnectionCallbacks = false);
~QuicClientTransport() override; ~QuicClientTransport() override;
@@ -59,9 +61,14 @@ class QuicClientTransport
folly::EventBase* evb, folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> sock, std::unique_ptr<folly::AsyncUDPSocket> sock,
std::shared_ptr<ClientHandshakeFactory> handshakeFactory, std::shared_ptr<ClientHandshakeFactory> handshakeFactory,
size_t connectionIdSize = 0) { size_t connectionIdSize = 0,
bool useSplitConnectionCallbacks = false) {
auto client = std::make_shared<TransportType>( auto client = std::make_shared<TransportType>(
evb, std::move(sock), std::move(handshakeFactory), connectionIdSize); evb,
std::move(sock),
std::move(handshakeFactory),
connectionIdSize,
useSplitConnectionCallbacks);
client->setSelfOwning(); client->setSelfOwning();
return client; return client;
} }

View File

@@ -85,12 +85,14 @@ class TestingQuicClientTransport : public QuicClientTransport {
folly::EventBase* evb, folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket, std::unique_ptr<folly::AsyncUDPSocket> socket,
std::shared_ptr<ClientHandshakeFactory> handshakeFactory, std::shared_ptr<ClientHandshakeFactory> handshakeFactory,
size_t connIdSize = kDefaultConnectionIdSize) size_t connIdSize = kDefaultConnectionIdSize,
bool useSplitConnectionCallbacks = false)
: QuicClientTransport( : QuicClientTransport(
evb, evb,
std::move(socket), std::move(socket),
std::move(handshakeFactory), std::move(handshakeFactory),
connIdSize) {} connIdSize,
useSplitConnectionCallbacks) {}
~TestingQuicClientTransport() override { ~TestingQuicClientTransport() override {
if (destructionCallback_) { if (destructionCallback_) {

View File

@@ -43,7 +43,11 @@ QuicServerTransport::QuicServerTransport(
ConnectionCallback& cb, ConnectionCallback& cb,
std::shared_ptr<const fizz::server::FizzServerContext> ctx, std::shared_ptr<const fizz::server::FizzServerContext> ctx,
std::unique_ptr<CryptoFactory> cryptoFactory) std::unique_ptr<CryptoFactory> cryptoFactory)
: QuicTransportBase(evb, std::move(sock)), ctx_(std::move(ctx)) { : QuicTransportBase(
evb,
std::move(sock),
false /* useSplitConnectionCallbacks */),
ctx_(std::move(ctx)) {
auto tempConn = std::make_unique<QuicServerConnectionState>( auto tempConn = std::make_unique<QuicServerConnectionState>(
FizzServerQuicHandshakeContext::Builder() FizzServerQuicHandshakeContext::Builder()
.setFizzServerContext(ctx_) .setFizzServerContext(ctx_)