ApiListener::ConfigUpdateHandler(): block as less as possible

refs #7742
This commit is contained in:
Alexander A. Klimov 2020-03-23 17:31:59 +01:00
parent 71cefb9ea4
commit dc3062a9b0
2 changed files with 8 additions and 2 deletions

View File

@ -13,6 +13,7 @@
#include "base/utility.hpp"
#include <fstream>
#include <iomanip>
#include <thread>
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;
}
/**

View File

@ -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);