aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/proxy
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenserver/proxy')
-rw-r--r--src/zenserver/proxy/zenproxyserver.cpp4
-rw-r--r--src/zenserver/proxy/zenproxyserver.h15
2 files changed, 10 insertions, 9 deletions
diff --git a/src/zenserver/proxy/zenproxyserver.cpp b/src/zenserver/proxy/zenproxyserver.cpp
index 1fd9cd2c4..acfdad45f 100644
--- a/src/zenserver/proxy/zenproxyserver.cpp
+++ b/src/zenserver/proxy/zenproxyserver.cpp
@@ -302,7 +302,7 @@ ZenProxyServer::Initialize(const ZenProxyServerConfig& ServerConfig, ZenServerSt
// Keep the io_context alive even when there is no pending work, so that
// worker threads don't exit prematurely between async operations.
- m_ProxyIoWorkGuard = std::make_unique<asio::io_context::work>(m_ProxyIoContext);
+ m_ProxyIoWorkGuard.emplace(m_ProxyIoContext.get_executor());
// Start proxy I/O worker threads. Use a modest thread count — proxy work is
// I/O-bound so we don't need a thread per core, but having more than one
@@ -404,7 +404,7 @@ ZenProxyServer::Cleanup()
Service->Stop();
}
- m_ProxyIoWorkGuard.reset();
+ m_ProxyIoWorkGuard.reset(); // releases the work guard, allowing io_context to finish
m_ProxyIoContext.stop();
for (auto& Thread : m_ProxyIoThreads)
{
diff --git a/src/zenserver/proxy/zenproxyserver.h b/src/zenserver/proxy/zenproxyserver.h
index 7dad748cf..329ca5235 100644
--- a/src/zenserver/proxy/zenproxyserver.h
+++ b/src/zenserver/proxy/zenproxyserver.h
@@ -7,6 +7,7 @@
#include "proxy/tcpproxy.h"
#include <memory>
+#include <optional>
#include <thread>
#include <vector>
@@ -84,13 +85,13 @@ public:
void Cleanup();
private:
- asio::io_context m_ProxyIoContext;
- std::unique_ptr<asio::io_context::work> m_ProxyIoWorkGuard;
- std::vector<std::thread> m_ProxyIoThreads;
- std::vector<std::unique_ptr<TcpProxyService>> m_ProxyServices;
- std::unique_ptr<HttpApiService> m_ApiService;
- std::unique_ptr<HttpFrontendService> m_FrontendService;
- std::unique_ptr<HttpProxyStatsService> m_ProxyStatsService;
+ asio::io_context m_ProxyIoContext;
+ std::optional<asio::executor_work_guard<asio::io_context::executor_type>> m_ProxyIoWorkGuard;
+ std::vector<std::thread> m_ProxyIoThreads;
+ std::vector<std::unique_ptr<TcpProxyService>> m_ProxyServices;
+ std::unique_ptr<HttpApiService> m_ApiService;
+ std::unique_ptr<HttpFrontendService> m_FrontendService;
+ std::unique_ptr<HttpProxyStatsService> m_ProxyStatsService;
};
} // namespace zen