aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/httpsys.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-09-27 16:25:15 +0200
committerGitHub <[email protected]>2023-09-27 16:25:15 +0200
commitc9e43e1ad5ea3f41e1f7df876460ede167d76351 (patch)
treee554bfd12d1ac21f33d5cbfcf99cc24cd441c93d /src/zenhttp/httpsys.cpp
parentchache upstream stats improved (#426) (diff)
downloadzen-c9e43e1ad5ea3f41e1f7df876460ede167d76351.tar.xz
zen-c9e43e1ad5ea3f41e1f7df876460ede167d76351.zip
prefer to handle cache RPC requests synchronously (#428)
* only handle RPC requests in a worker thread if we have an upstream. we may as well handle the request inline on the http_io thread if we're only dealing with local data since the response times should be pretty consistent in that case * http.sys: don't create async worker thread pool until it's needed (typically only if we have an upstream)
Diffstat (limited to 'src/zenhttp/httpsys.cpp')
-rw-r--r--src/zenhttp/httpsys.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/zenhttp/httpsys.cpp b/src/zenhttp/httpsys.cpp
index f95a31914..886d53143 100644
--- a/src/zenhttp/httpsys.cpp
+++ b/src/zenhttp/httpsys.cpp
@@ -747,7 +747,7 @@ HttpSysServer::HttpSysServer(const Config& Config)
, m_IsRequestLoggingEnabled(Config.IsRequestLoggingEnabled)
, m_IsAsyncResponseEnabled(Config.IsAsyncResponseEnabled)
, m_ThreadPool(Config.ThreadCount != 0 ? Config.ThreadCount : std::thread::hardware_concurrency())
-, m_AsyncWorkPool(Config.AsyncWorkThreadCount != 0 ? Config.AsyncWorkThreadCount : 16, "http_async")
+, m_InitialConfig(Config)
{
ULONG Result = HttpInitialize(HTTPAPI_VERSION_2, HTTP_INITIALIZE_SERVER, nullptr);
@@ -768,6 +768,9 @@ HttpSysServer::~HttpSysServer()
{
ZEN_ERROR("~HttpSysServer() called without calling Close() first");
}
+
+ delete m_AsyncWorkPool;
+ m_AsyncWorkPool = nullptr;
}
void
@@ -977,6 +980,24 @@ HttpSysServer::Cleanup()
}
}
+WorkerThreadPool&
+HttpSysServer::WorkPool()
+{
+ if (!m_AsyncWorkPool)
+ {
+ RwLock::ExclusiveLockScope _(m_AsyncWorkPoolInitLock);
+
+ if (!m_AsyncWorkPool)
+ {
+ unsigned int WorkerThreadCount = m_InitialConfig.AsyncWorkThreadCount != 0 ? m_InitialConfig.AsyncWorkThreadCount : 16;
+
+ m_AsyncWorkPool = new WorkerThreadPool(WorkerThreadCount, "http_async");
+ }
+ }
+
+ return *m_AsyncWorkPool;
+}
+
void
HttpSysServer::StartServer()
{