aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/servers/httpsys.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-02-24 11:31:07 +0100
committerStefan Boberg <[email protected]>2026-02-24 11:31:07 +0100
commit590eb9504d56ca026a4a315e6c28ce7d46b2b8bd (patch)
tree5d5134c74d57f5955c09886fb15fbcda4fdc3868 /src/zenhttp/servers/httpsys.cpp
parentfixed up orchestrator member naming (diff)
downloadzen-590eb9504d56ca026a4a315e6c28ce7d46b2b8bd.tar.xz
zen-590eb9504d56ca026a4a315e6c28ce7d46b2b8bd.zip
fix m_AsyncWorkPool threading issue
Diffstat (limited to 'src/zenhttp/servers/httpsys.cpp')
-rw-r--r--src/zenhttp/servers/httpsys.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/zenhttp/servers/httpsys.cpp b/src/zenhttp/servers/httpsys.cpp
index 020b9d134..c44549a5a 100644
--- a/src/zenhttp/servers/httpsys.cpp
+++ b/src/zenhttp/servers/httpsys.cpp
@@ -26,6 +26,7 @@
# include <zencore/workthreadpool.h>
# include "iothreadpool.h"
+# include <atomic>
# include <http.h>
# include <asio.hpp> // for resolving addresses for GetExternalHost
@@ -132,8 +133,8 @@ private:
std::unique_ptr<WinIoThreadPool> m_IoThreadPool;
- RwLock m_AsyncWorkPoolInitLock;
- WorkerThreadPool* m_AsyncWorkPool = nullptr;
+ RwLock m_AsyncWorkPoolInitLock;
+ std::atomic<WorkerThreadPool*> m_AsyncWorkPool = nullptr;
std::vector<std::wstring> m_BaseUris; // eg: http://*:nnnn/
HTTP_SERVER_SESSION_ID m_HttpSessionId = 0;
@@ -1035,8 +1036,8 @@ HttpSysServer::~HttpSysServer()
ZEN_ERROR("~HttpSysServer() called without calling Close() first");
}
- delete m_AsyncWorkPool;
- m_AsyncWorkPool = nullptr;
+ delete m_AsyncWorkPool.load(std::memory_order_relaxed);
+ m_AsyncWorkPool.store(nullptr, std::memory_order_relaxed);
}
void
@@ -1326,17 +1327,17 @@ HttpSysServer::WorkPool()
{
ZEN_MEMSCOPE(GetHttpsysTag());
- if (!m_AsyncWorkPool)
+ if (!m_AsyncWorkPool.load(std::memory_order_acquire))
{
RwLock::ExclusiveLockScope _(m_AsyncWorkPoolInitLock);
- if (!m_AsyncWorkPool)
+ if (!m_AsyncWorkPool.load(std::memory_order_relaxed))
{
- m_AsyncWorkPool = new WorkerThreadPool(m_InitialConfig.AsyncWorkThreadCount, "http_async");
+ m_AsyncWorkPool.store(new WorkerThreadPool(m_InitialConfig.AsyncWorkThreadCount, "http_async"), std::memory_order_release);
}
}
- return *m_AsyncWorkPool;
+ return *m_AsyncWorkPool.load(std::memory_order_relaxed);
}
void