Skip to content

Commit

Permalink
tools: remove ioContextRunner
Browse files Browse the repository at this point in the history
Change-Id: I0ce66802ef962d8ff01ffea800224b2d2ed72ac4
  • Loading branch information
AmnaSnene committed Aug 16, 2024
1 parent 084d8a3 commit 5170f76
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 37 deletions.
12 changes: 1 addition & 11 deletions tools/dnc/dnc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,7 @@ Dnc::Dnc(dht::crypto::Identity identity,
ioContext(std::make_shared<asio::io_context>()),
iceFactory(std::make_shared<IceTransportFactory>(logger))
{
ioContextRunner = std::thread([context = ioContext, logger = logger] {
try {
auto work = asio::make_work_guard(*context);
context->run();
} catch (const std::exception& ex) {
if (logger)
logger->error("Error in ioContextRunner: {}", ex.what());
}
});


certStore = std::make_shared<tls::CertificateStore>(cachePath()/"certStore", logger);
trustStore = std::make_shared<tls::TrustStore>(*certStore);

Expand Down Expand Up @@ -254,6 +245,5 @@ Dnc::run()
Dnc::~Dnc()
{
ioContext->stop();
ioContextRunner.join();
}
} // namespace dhtnet
1 change: 0 additions & 1 deletion tools/dnc/dnc.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class Dnc
std::shared_ptr<tls::CertificateStore> certStore;
std::shared_ptr<IceTransportFactory> iceFactory;
std::shared_ptr<asio::io_context> ioContext;
std::thread ioContextRunner;
std::shared_ptr<tls::TrustStore> trustStore;

std::pair<std::string, std::string> parseName(const std::string_view name);
Expand Down
15 changes: 2 additions & 13 deletions tools/dsh/dsh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,12 @@ dhtnet::Dsh::Dsh(dht::crypto::Identity identity,
const std::string& turn_pass,
const std::string& turn_realm,
bool anonymous)
:logger(dht::log::getStdLogger())
, ioContext(std::make_shared<asio::io_context>()),
:logger(dht::log::getStdLogger()),
ioContext(std::make_shared<asio::io_context>()),
iceFactory(std::make_shared<IceTransportFactory>(logger)),
certStore(std::make_shared<tls::CertificateStore>(cachePath()/"certstore", logger)),
trustStore(std::make_shared<tls::TrustStore>(*certStore))
{
ioContext = std::make_shared<asio::io_context>();
ioContextRunner = std::thread([context = ioContext, logger = logger] {
try {
auto work = asio::make_work_guard(*context);
context->run();
} catch (const std::exception& ex) {
if (logger)
logger->error("Error in ioContextRunner: {}", ex.what());
}
});
auto ca = identity.second->issuer;
trustStore->setCertificateStatus(ca->getId().toString(), tls::TrustStore::PermissionStatus::ALLOWED);
// Build a server
Expand Down Expand Up @@ -272,7 +262,6 @@ dhtnet::Dsh::run()
dhtnet::Dsh::~Dsh()
{
ioContext->stop();
ioContextRunner.join();
}

} // namespace dhtnet
1 change: 0 additions & 1 deletion tools/dsh/dsh.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class Dsh
std::shared_ptr<tls::CertificateStore> certStore {nullptr};
std::shared_ptr<dhtnet::IceTransportFactory> iceFactory {nullptr};
std::shared_ptr<asio::io_context> ioContext;
std::thread ioContextRunner;
std::shared_ptr<tls::TrustStore> trustStore;

};
Expand Down
10 changes: 0 additions & 10 deletions tools/dvpn/dvpn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,6 @@ dhtnet::Dvpn::Dvpn(dht::crypto::Identity identity,
certStore(std::make_shared<tls::CertificateStore>(cachePath()/"certstore", logger)),
trustStore(std::make_shared<tls::TrustStore>(*certStore))
{
ioContextRunner = std::thread([context = ioContext, logger = logger] {
try {
auto work = asio::make_work_guard(*context);
context->run();
} catch (const std::exception& ex) {
if (logger)
logger->error("Error in ioContextRunner: {}", ex.what());
}
});
auto ca = identity.second->issuer;
trustStore->setCertificateStatus(ca->getId().toString(), tls::TrustStore::PermissionStatus::ALLOWED);

Expand Down Expand Up @@ -386,5 +377,4 @@ dhtnet::Dvpn::run()
dhtnet::Dvpn::~Dvpn()
{
ioContext->stop();
ioContextRunner.join();
}
1 change: 0 additions & 1 deletion tools/dvpn/dvpn.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class Dvpn
std::shared_ptr<tls::CertificateStore> certStore;
std::shared_ptr<IceTransportFactory> iceFactory;
std::shared_ptr<asio::io_context> ioContext;
std::thread ioContextRunner;
enum class CommunicationState { METADATA, DATA };
std::shared_ptr<tls::TrustStore> trustStore;
};
Expand Down

0 comments on commit 5170f76

Please sign in to comment.