From c704f99d2e55884b6e60206f18b41f8faf03da96 Mon Sep 17 00:00:00 2001 From: aiwe Date: Sun, 18 Jun 2023 10:35:14 -0500 Subject: [PATCH] Change the launch of http(s) server in RpcServer --- src/Rpc/RpcServer.cpp | 14 ++++++++------ src/Rpc/RpcServer.h | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Rpc/RpcServer.cpp b/src/Rpc/RpcServer.cpp index d9b30dbdeb..f6b2d9ffbe 100755 --- a/src/Rpc/RpcServer.cpp +++ b/src/Rpc/RpcServer.cpp @@ -273,17 +273,13 @@ void RpcServer::start() { uint16_t ssl_port = m_config.getBindPortSSL(); // make sure to use separate port for SSL server logger(Logging::DEBUGGING, Logging::BRIGHT_MAGENTA) << "bind https to port " << ssl_port << ENDL; - m_workers.emplace_back(std::unique_ptr>( - new System::RemoteContext(m_dispatcher, std::bind(&RpcServer::listen_ssl, this, address, ssl_port))) - ); + m_workers.push_back(std::thread(std::bind(&RpcServer::listen_ssl, this, address, ssl_port))); } uint16_t port = m_config.getBindPort(); logger(Logging::DEBUGGING, Logging::BRIGHT_MAGENTA) << "bind http to port " << port << ENDL; - m_workers.emplace_back(std::unique_ptr>( - new System::RemoteContext(m_dispatcher, std::bind(&RpcServer::listen, this, address, port))) - ); + m_workers.push_back(std::thread(std::bind(&RpcServer::listen, this, address, port))); } void RpcServer::stop() { @@ -293,6 +289,12 @@ void RpcServer::stop() { http->stop(); + for (auto& th : m_workers) { + if (th.joinable()) { + th.join(); + } + } + m_workers.clear(); } diff --git a/src/Rpc/RpcServer.h b/src/Rpc/RpcServer.h index 5b43bf1446..37a77f2d89 100755 --- a/src/Rpc/RpcServer.h +++ b/src/Rpc/RpcServer.h @@ -19,6 +19,7 @@ #pragma once +#include #include #include #include @@ -173,7 +174,7 @@ class RpcServer { Crypto::SecretKey m_view_key; CryptoNote::AccountPublicAddress m_fee_acc; - std::vector>> m_workers; + std::list m_workers; };