diff options
| author | Stefan Boberg <[email protected]> | 2023-05-15 17:55:52 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-15 17:55:52 +0200 |
| commit | 14f4baabfa56eedb7b71235b951e993da4f641ef (patch) | |
| tree | 86c08838a0179ae15910b791a1412c448340020d /src/zenhttp/httpsys.cpp | |
| parent | v0.2.11 (diff) | |
| download | zen-14f4baabfa56eedb7b71235b951e993da4f641ef.tar.xz zen-14f4baabfa56eedb7b71235b951e993da4f641ef.zip | |
all threads should be named (#304)
* added WorkerThreadPool naming, packaged_task support
* name the http.sys thread pool service threads
* added http.sys I/O threadpool naming
* upstream cache I/O thread naming
Diffstat (limited to 'src/zenhttp/httpsys.cpp')
| -rw-r--r-- | src/zenhttp/httpsys.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/zenhttp/httpsys.cpp b/src/zenhttp/httpsys.cpp index 25e4393b3..979f69aeb 100644 --- a/src/zenhttp/httpsys.cpp +++ b/src/zenhttp/httpsys.cpp @@ -178,7 +178,7 @@ class HttpSysServerRequest : public HttpServerRequest { public: HttpSysServerRequest(HttpSysTransaction& Tx, HttpService& Service, IoBuffer PayloadBuffer); - ~HttpSysServerRequest() = default; + ~HttpSysServerRequest(); virtual Oid ParseSessionId() const override; virtual uint32_t ParseRequestId() const override; @@ -722,7 +722,7 @@ HttpSysServer::HttpSysServer(unsigned int ThreadCount, unsigned int AsyncWorkThr : m_Log(logging::Get("http")) , m_RequestLog(logging::Get("http_requests")) , m_ThreadPool(ThreadCount) -, m_AsyncWorkPool(AsyncWorkThreadCount) +, m_AsyncWorkPool(AsyncWorkThreadCount, "http_async") { ULONG Result = HttpInitialize(HTTPAPI_VERSION_2, HTTP_INITIALIZE_SERVER, nullptr); @@ -1093,6 +1093,9 @@ HttpSysTransaction::IssueInitialRequest(std::error_code& ErrorCode) m_InitialHttpHandler.IssueRequest(ErrorCode); } +thread_local bool t_IsHttpSysThreadNamed = false; +static std::atomic<int> HttpSysThreadIndex = 0; + void HttpSysTransaction::IoCompletionCallback(PTP_CALLBACK_INSTANCE Instance, PVOID pContext /* HttpSysServer */, @@ -1105,6 +1108,17 @@ HttpSysTransaction::IoCompletionCallback(PTP_CALLBACK_INSTANCE Instance, UNREFERENCED_PARAMETER(Instance); UNREFERENCED_PARAMETER(pContext); + // Assign names to threads for context + + if (!t_IsHttpSysThreadNamed) + { + t_IsHttpSysThreadNamed = true; + const int ThreadIndex = ++HttpSysThreadIndex; + zen::ExtendableStringBuilder<128> ThreadName; + ThreadName << "httpio_" << ThreadIndex; + SetCurrentThreadName(ThreadName); + } + // Note that for a given transaction we may be in this completion function on more // than one thread at any given moment. This means we need to be careful about what // happens in here @@ -1306,6 +1320,10 @@ HttpSysServerRequest::HttpSysServerRequest(HttpSysTransaction& Tx, HttpService& } } +HttpSysServerRequest::~HttpSysServerRequest() +{ +} + Oid HttpSysServerRequest::ParseSessionId() const { |