tools: remove ioContextRunner
Change-Id: I0ce66802ef962d8ff01ffea800224b2d2ed72ac4
diff --git a/tools/dnc/dnc.cpp b/tools/dnc/dnc.cpp
index 8fce1de..db21477 100644
--- a/tools/dnc/dnc.cpp
+++ b/tools/dnc/dnc.cpp
@@ -67,16 +67,7 @@
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);
@@ -254,6 +245,5 @@
Dnc::~Dnc()
{
ioContext->stop();
- ioContextRunner.join();
}
} // namespace dhtnet
diff --git a/tools/dnc/dnc.h b/tools/dnc/dnc.h
index 7d03cc9..93132b6 100644
--- a/tools/dnc/dnc.h
+++ b/tools/dnc/dnc.h
@@ -65,7 +65,6 @@
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);
diff --git a/tools/dsh/dsh.cpp b/tools/dsh/dsh.cpp
index 8456612..5f32d4e 100644
--- a/tools/dsh/dsh.cpp
+++ b/tools/dsh/dsh.cpp
@@ -92,22 +92,12 @@
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
@@ -272,7 +262,6 @@
dhtnet::Dsh::~Dsh()
{
ioContext->stop();
- ioContextRunner.join();
}
} // namespace dhtnet
\ No newline at end of file
diff --git a/tools/dsh/dsh.h b/tools/dsh/dsh.h
index ec983a2..1c8759e 100644
--- a/tools/dsh/dsh.h
+++ b/tools/dsh/dsh.h
@@ -52,7 +52,6 @@
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;
};
diff --git a/tools/dvpn/dvpn.cpp b/tools/dvpn/dvpn.cpp
index f6214a3..ac4536f 100644
--- a/tools/dvpn/dvpn.cpp
+++ b/tools/dvpn/dvpn.cpp
@@ -169,15 +169,6 @@
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);
@@ -386,5 +377,4 @@
dhtnet::Dvpn::~Dvpn()
{
ioContext->stop();
- ioContextRunner.join();
}
diff --git a/tools/dvpn/dvpn.h b/tools/dvpn/dvpn.h
index e17775a..0db11b2 100644
--- a/tools/dvpn/dvpn.h
+++ b/tools/dvpn/dvpn.h
@@ -63,7 +63,6 @@
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;
};