Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/MoqxPicoRelayServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ MoqxPicoRelayServer::~MoqxPicoRelayServer() {
}

void MoqxPicoRelayServer::stop() {
if (!context_) {
if (stopped_) {
return;
}
stopped_ = true;
// Keep context_ alive: terminateClientSession can run after stop() returns,
// from handleClientSession coroutines still draining on the evb.
context_->stop();
evb_->runImmediatelyOrRunInEventBaseThreadAndWait([this] { MoQPicoQuicEventBaseServer::stop(); });
context_.reset();
}

void MoqxPicoRelayServer::setStatsRegistry(std::shared_ptr<stats::StatsRegistry> registry) {
Expand Down
1 change: 1 addition & 0 deletions src/MoqxPicoRelayServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class MoqxPicoRelayServer : public moxygen::MoQPicoQuicEventBaseServer {
config::ListenerConfig listenerCfg_;
std::shared_ptr<MoqxRelayContext> context_;
folly::EventBase* evb_;
bool stopped_{false};
};

} // namespace openmoq::moqx
7 changes: 4 additions & 3 deletions src/MoqxRelayServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,13 @@ MoqxRelayServer::~MoqxRelayServer() {
}

void MoqxRelayServer::stop() {
if (!context_) {
if (stopped_) {
return;
}
// QuicServer::shutdown drives terminateClientSession, which uses context_.
stopped_ = true;
// Keep context_ alive: terminateClientSession can run after stop() returns,
// from handleClientSession coroutines still draining on IO threads.
MoQServer::stop();
context_.reset();
}

void MoqxRelayServer::setStatsRegistry(std::shared_ptr<stats::StatsRegistry> registry) {
Expand Down
1 change: 1 addition & 0 deletions src/MoqxRelayServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class MoqxRelayServer : public moxygen::MoQServer {
config::ListenerConfig listenerCfg_;
std::shared_ptr<MoqxRelayContext> context_;
folly::IOThreadPoolExecutor* ioExecutor_;
bool stopped_{false};
};

} // namespace openmoq::moqx
Loading