From dc3062a9b06fed69cdbb1508ace6eb2f77f87553 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 23 Mar 2020 17:31:59 +0100 Subject: [PATCH] ApiListener::ConfigUpdateHandler(): block as less as possible refs #7742 --- lib/remote/apilistener-filesync.cpp | 9 +++++++-- lib/remote/apilistener.hpp | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/remote/apilistener-filesync.cpp b/lib/remote/apilistener-filesync.cpp index 73a42eb8f..754e9ee58 100644 --- a/lib/remote/apilistener-filesync.cpp +++ b/lib/remote/apilistener-filesync.cpp @@ -13,6 +13,7 @@ #include "base/utility.hpp" #include #include +#include using namespace icinga; @@ -310,6 +311,12 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin::Ptr& origin, const D return Empty; } + std::thread([origin, params]() { HandleConfigUpdate(origin, params); }).detach(); + return Empty; +} + +void ApiListener::HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params) +{ /* Only one transaction is allowed, concurrent message handlers need to wait. * This affects two parent endpoints sending the config in the same moment. */ @@ -527,8 +534,6 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin::Ptr& origin, const D << "Received configuration updates (" << count << ") from endpoint '" << fromEndpointName << "' are equal to production, skipping validation and reload."; } - - return Empty; } /** diff --git a/lib/remote/apilistener.hpp b/lib/remote/apilistener.hpp index 37900d1a3..b0b5b83f4 100644 --- a/lib/remote/apilistener.hpp +++ b/lib/remote/apilistener.hpp @@ -85,6 +85,7 @@ public: /* filesync */ static Value ConfigUpdateHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params); + static void HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params); /* configsync */ static void ConfigUpdateObjectHandler(const ConfigObject::Ptr& object, const Value& cookie);