1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-04-18 17:24:03 +03:00
mvfst/quic/server/QuicCcpThreadLauncher.cpp
Luca Niccolini 63ee419d75 Fix includes
Summary:
```
find quic -name \*.h -o -name \*.cpp | xargs sed -i'' -E "s/#include \"(.*)\"/#include <\1>/"
arc lint -a --paths-cmd 'hg files quic/'
```

Reviewed By: mjoras

Differential Revision: D34199869

fbshipit-source-id: 3633cb8429b86c03ab367211d6a46dbe4fdd5ff2
2022-02-14 23:56:30 -08:00

48 lines
1.0 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <quic/server/QuicCcpThreadLauncher.h>
namespace quic {
void QuicCcpThreadLauncher::start(
FOLLY_MAYBE_UNUSED const std::string& ccpConfig) {
#ifdef CCP_ENABLED
ccpId_ = folly::Random::secureRand64();
handle_ = ccp_create_handle();
ccpEvb_.getEventBase()->runInEventBaseThread([&, handle = handle_] {
// NOTE second arg is fd of output device
// hardcoded to 2 for stderr
ccp_spawn(ccpConfig.c_str(), 2, ccpId_, handle);
});
#else
VLOG(2) << "WARN: tried to launch ccp, but ccp not enabled";
#endif
}
bool QuicCcpThreadLauncher::hasLaunched() {
return ccpId_ != 0;
}
uint64_t QuicCcpThreadLauncher::getCcpId() {
#ifdef CCP_ENABLED
return ccpId_;
#else
return 0;
#endif
}
void QuicCcpThreadLauncher::stop() {
#ifdef CCP_ENABLED
if (hasLaunched_()) {
ccp_kill(handle_);
}
#else
#endif
}
} // namespace quic