aboutsummaryrefslogtreecommitdiff
path: root/zenserver/monitoring/httpstatus.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-10-11 13:18:37 +0200
committerStefan Boberg <[email protected]>2021-10-11 13:18:37 +0200
commit37bf16575d226e6b53579eb913f70f869d3c3ec4 (patch)
treea677062fe7a0c4c318b7a36cb94a18fd203996dc /zenserver/monitoring/httpstatus.cpp
parentAdded lofreq timer update to httpsys main loop (diff)
downloadzen-37bf16575d226e6b53579eb913f70f869d3c3ec4.tar.xz
zen-37bf16575d226e6b53579eb913f70f869d3c3ec4.zip
stats: Added support for handler unregistration
Diffstat (limited to 'zenserver/monitoring/httpstatus.cpp')
-rw-r--r--zenserver/monitoring/httpstatus.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/zenserver/monitoring/httpstatus.cpp b/zenserver/monitoring/httpstatus.cpp
index e12662b1c..8b10601dd 100644
--- a/zenserver/monitoring/httpstatus.cpp
+++ b/zenserver/monitoring/httpstatus.cpp
@@ -26,6 +26,15 @@ HttpStatusService::RegisterHandler(std::string_view Id, IHttpStatusProvider& Pro
}
void
+HttpStatusService::UnregisterHandler(std::string_view Id, IHttpStatusProvider& Provider)
+{
+ ZEN_UNUSED(Provider);
+
+ RwLock::ExclusiveLockScope _(m_Lock);
+ m_Providers.erase(std::string(Id));
+}
+
+void
HttpStatusService::HandleRequest(HttpServerRequest& Request)
{
using namespace std::literals;
@@ -36,9 +45,12 @@ HttpStatusService::HandleRequest(HttpServerRequest& Request)
{
case HttpVerb::kHead:
case HttpVerb::kGet:
- if (auto It = m_Providers.find(std::string{Key}); It != end(m_Providers))
{
- return It->second->HandleStatusRequest(Request);
+ RwLock::SharedLockScope _(m_Lock);
+ if (auto It = m_Providers.find(std::string{Key}); It != end(m_Providers))
+ {
+ return It->second->HandleStatusRequest(Request);
+ }
}
[[fallthrough]];