Skip to content

Commit

Permalink
mark private QuicServerWorker::WorkerCallback overrides and additiona…
Browse files Browse the repository at this point in the history
…l evb parameter

Summary:
- there's no need to publicly expose QuicServerWorker::WorkerCallback overrides in QuicServer

- modified `::routeDataToWorker` function signature to take an additional EventBase argument, set to the EventBase of the QuicServerWorker that is invoking the cb function

- additional argument used in the next diff to fetch the associated worker with the eventbase

Reviewed By: sharmafb

Differential Revision: D52435341

fbshipit-source-id: 779cf3aba86f408dbb746aa0a573d0618d7e4cb4
  • Loading branch information
hanidamlaj authored and facebook-github-bot committed Jan 11, 2024
1 parent 66383e3 commit 0bd5725
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 20 deletions.
1 change: 1 addition & 0 deletions quic/server/QuicServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ void QuicServer::routeDataToWorker(
RoutingData&& routingData,
NetworkData&& networkData,
folly::Optional<QuicVersion> quicVersion,
folly::EventBase*,
bool isForwardedData) {
// figure out worker idx
if (!initialized_) {
Expand Down
27 changes: 14 additions & 13 deletions quic/server/QuicServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,6 @@ class QuicServer : public QuicServerWorker::WorkerCallback,
*/
void waitUntilInitialized();

void handleWorkerError(LocalErrorCode error) override;

/**
* Routes the given data for the given client to the correct worker that may
* have the state for the connection associated with the given data and client
*/
void routeDataToWorker(
const folly::SocketAddress& client,
RoutingData&& routingData,
NetworkData&& networkData,
folly::Optional<QuicVersion> quicVersion,
bool isForwardedData = false) override;

/**
* Set the transport factory for the worker associated with the given
* eventbase.
Expand Down Expand Up @@ -365,6 +352,20 @@ class QuicServer : public QuicServerWorker::WorkerCallback,
private:
QuicServer();

/**
* Routes the given data for the given client to the correct worker that may
* have the state for the connection associated with the given data and client
*/
void routeDataToWorker(
const folly::SocketAddress& client,
RoutingData&& routingData,
NetworkData&& networkData,
folly::Optional<QuicVersion> quicVersion,
folly::EventBase* workerEvb,
bool isForwardedData = false) override;

void handleWorkerError(LocalErrorCode error) override;

using MaybeOwnedEvbPtr =
std::unique_ptr<folly::IOExecutor, void (*)(folly::IOExecutor*)>;

Expand Down
1 change: 1 addition & 0 deletions quic/server/QuicServerWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ void QuicServerWorker::forwardNetworkData(
std::move(routingData),
std::move(networkData),
std::move(quicVersion),
getEventBase(),
isForwardedData);
}

Expand Down
1 change: 1 addition & 0 deletions quic/server/QuicServerWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class QuicServerWorker : public FollyAsyncUDPSocketAlias::ReadCallback,
RoutingData&& routingData,
NetworkData&& networkData,
folly::Optional<QuicVersion> quicVersion,
folly::EventBase* workerEvb,
bool isForwardedData) = 0;
};

Expand Down
1 change: 1 addition & 0 deletions quic/server/test/Mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class MockWorkerCallback : public QuicServerWorker::WorkerCallback {
RoutingData&& routingDataIn,
NetworkData&& networkDataIn,
folly::Optional<QuicVersion> quicVersion,
folly::EventBase*,
bool isForwardedData = false) {
auto routingData = std::make_unique<RoutingData>(std::move(routingDataIn));
auto networkData = std::make_unique<NetworkData>(std::move(networkDataIn));
Expand Down
23 changes: 16 additions & 7 deletions quic/server/test/QuicServerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2269,8 +2269,14 @@ TEST_F(QuicServerTest, DontRouteDataAfterShutdown) {
false,
header.getDestinationConnId(),
header.getSourceConnId());
server_->routeDataToWorker(
kClientAddr, std::move(routingData), std::move(networkData), version);
static_cast<QuicServerWorker::WorkerCallback*>(server_.get())
->routeDataToWorker(
kClientAddr,
std::move(routingData),
std::move(networkData),
version,
evbThread.getEventBase(),
/*isForwardedData=*/false);
}));
std::thread t([&] { server_->shutdown(); });
t.join();
Expand Down Expand Up @@ -2324,11 +2330,14 @@ TEST_F(QuicServerTest, RouteDataFromDifferentThread) {
*networkData.getPackets()[0].buf, *initialData));
}));

server_->routeDataToWorker(
client->address(),
std::move(routingData),
std::move(networkData),
version);
static_cast<QuicServerWorker::WorkerCallback*>(server_.get())
->routeDataToWorker(
client->address(),
std::move(routingData),
std::move(networkData),
version,
evbThread.getEventBase(),
/*isForwardedData=*/false);

// cleanup transport
transport->getEventBase()->runInEventBaseThreadAndWait(
Expand Down

0 comments on commit 0bd5725

Please sign in to comment.