Skip to content

Commit

Permalink
ApiListener::ConfigUpdateHandler(): block as less as possible
Browse files Browse the repository at this point in the history
refs #7742
  • Loading branch information
Al2Klimov committed Jul 7, 2020
1 parent 6a19931 commit 4d80903
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/remote/apilistener-filesync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "base/utility.hpp"
#include <fstream>
#include <iomanip>
#include <thread>

using namespace icinga;

Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -527,8 +534,6 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin::Ptr& origin, const D
<< "Received configuration updates (" << count << ") from endpoint '" << fromEndpointName
<< "' do not qualify for production, not triggering reload.";
}

return Empty;
}

/**
Expand Down
1 change: 1 addition & 0 deletions lib/remote/apilistener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class ApiListener final : public ObjectImpl<ApiListener>

/* 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);
Expand Down

0 comments on commit 4d80903

Please sign in to comment.