aboutsummaryrefslogtreecommitdiff
path: root/zenserver/monitoring/httpstats.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/httpstats.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/httpstats.cpp')
-rw-r--r--zenserver/monitoring/httpstats.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/zenserver/monitoring/httpstats.cpp b/zenserver/monitoring/httpstats.cpp
index de04294d0..4d985f8c2 100644
--- a/zenserver/monitoring/httpstats.cpp
+++ b/zenserver/monitoring/httpstats.cpp
@@ -26,6 +26,15 @@ HttpStatsService::RegisterHandler(std::string_view Id, IHttpStatsProvider& Provi
}
void
+HttpStatsService::UnregisterHandler(std::string_view Id, IHttpStatsProvider& Provider)
+{
+ ZEN_UNUSED(Provider);
+
+ RwLock::ExclusiveLockScope _(m_Lock);
+ m_Providers.erase(std::string(Id));
+}
+
+void
HttpStatsService::HandleRequest(HttpServerRequest& Request)
{
using namespace std::literals;
@@ -36,9 +45,12 @@ HttpStatsService::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->HandleStatsRequest(Request);
+ RwLock::SharedLockScope _(m_Lock);
+ if (auto It = m_Providers.find(std::string{Key}); It != end(m_Providers))
+ {
+ return It->second->HandleStatsRequest(Request);
+ }
}
[[fallthrough]];