Skip to content

Commit

Permalink
Change the launch of http(s) server in RpcServer
Browse files Browse the repository at this point in the history
  • Loading branch information
aivve committed Jun 18, 2023
1 parent 7dcd900 commit c704f99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 8 additions & 6 deletions src/Rpc/RpcServer.cpp
Expand Up @@ -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<System::RemoteContext<void>>(
new System::RemoteContext<void>(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<System::RemoteContext<void>>(
new System::RemoteContext<void>(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() {
Expand All @@ -293,6 +289,12 @@ void RpcServer::stop() {

http->stop();

for (auto& th : m_workers) {
if (th.joinable()) {
th.join();
}
}

m_workers.clear();
}

Expand Down
3 changes: 2 additions & 1 deletion src/Rpc/RpcServer.h
Expand Up @@ -19,6 +19,7 @@

#pragma once

#include <list>
#include <thread>
#include <functional>
#include <unordered_map>
Expand Down Expand Up @@ -173,7 +174,7 @@ class RpcServer {
Crypto::SecretKey m_view_key;
CryptoNote::AccountPublicAddress m_fee_acc;

std::vector<std::unique_ptr<System::RemoteContext<void>>> m_workers;
std::list<std::thread> m_workers;

};

Expand Down

0 comments on commit c704f99

Please sign in to comment.