From 5170f76d79bef7f031434d365ef5f336a49d1054 Mon Sep 17 00:00:00 2001 From: Amna <amna.snene@savoirfairelinux.com> Date: Fri, 16 Aug 2024 11:49:56 -0400 Subject: [PATCH] tools: remove ioContextRunner Change-Id: I0ce66802ef962d8ff01ffea800224b2d2ed72ac4 --- tools/dnc/dnc.cpp | 12 +----------- tools/dnc/dnc.h | 1 - tools/dsh/dsh.cpp | 15 ++------------- tools/dsh/dsh.h | 1 - tools/dvpn/dvpn.cpp | 10 ---------- tools/dvpn/dvpn.h | 1 - 6 files changed, 3 insertions(+), 37 deletions(-) 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 @@ 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); @@ -254,6 +245,5 @@ Dnc::run() 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 @@ private: 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 @@ 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 @@ -272,7 +262,6 @@ dhtnet::Dsh::run() 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 @@ private: 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 @@ 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); @@ -386,5 +377,4 @@ dhtnet::Dvpn::run() 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 @@ public: 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; }; -- GitLab