From 37bf16575d226e6b53579eb913f70f869d3c3ec4 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Mon, 11 Oct 2021 13:18:37 +0200 Subject: stats: Added support for handler unregistration --- zenserver/monitoring/httpstatus.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'zenserver/monitoring/httpstatus.cpp') 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 @@ -25,6 +25,15 @@ HttpStatusService::RegisterHandler(std::string_view Id, IHttpStatusProvider& Pro m_Providers.insert_or_assign(std::string(Id), &Provider); } +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) { @@ -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]]; -- cgit v1.2.3