aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/httpserver.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index a022d220e0..a554dcb097 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -449,6 +449,7 @@ bool UpdateHTTPServerLogging(bool enable) {
std::thread threadHTTP;
std::future<bool> threadResult;
+static std::vector<std::thread> g_thread_http_workers;
bool StartHTTPServer()
{
@@ -460,8 +461,7 @@ bool StartHTTPServer()
threadHTTP = std::thread(std::move(task), eventBase, eventHTTP);
for (int i = 0; i < rpcThreads; i++) {
- std::thread rpc_worker(HTTPWorkQueueRun, workQueue);
- rpc_worker.detach();
+ g_thread_http_workers.emplace_back(HTTPWorkQueueRun, workQueue);
}
return true;
}
@@ -487,6 +487,10 @@ void StopHTTPServer()
if (workQueue) {
LogPrint(BCLog::HTTP, "Waiting for HTTP worker threads to exit\n");
workQueue->WaitExit();
+ for (auto& thread: g_thread_http_workers) {
+ thread.join();
+ }
+ g_thread_http_workers.clear();
delete workQueue;
workQueue = nullptr;
}