diff --git a/lib/remote/apilistener-filesync.cpp b/lib/remote/apilistener-filesync.cpp index 754e9ee58..1feb13097 100644 --- a/lib/remote/apilistener-filesync.cpp +++ b/lib/remote/apilistener-filesync.cpp @@ -10,6 +10,7 @@ #include "base/convert.hpp" #include "base/application.hpp" #include "base/exception.hpp" +#include "base/shared.hpp" #include "base/utility.hpp" #include #include @@ -320,7 +321,7 @@ void ApiListener::HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dic /* Only one transaction is allowed, concurrent message handlers need to wait. * This affects two parent endpoints sending the config in the same moment. */ - boost::mutex::scoped_lock lock(m_ConfigSyncStageLock); + auto lock (Shared::Make(m_ConfigSyncStageLock)); String apiZonesStageDir = GetApiZonesStageDir(); String fromEndpointName = origin->FromClient->GetEndpoint()->GetName(); @@ -528,7 +529,7 @@ void ApiListener::HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dic Log(LogInformation, "ApiListener") << "Received configuration updates (" << count << ") from endpoint '" << fromEndpointName << "' are different to production, triggering validation and reload."; - AsyncTryActivateZonesStage(relativePaths); + AsyncTryActivateZonesStage(relativePaths, lock); } else { Log(LogInformation, "ApiListener") << "Received configuration updates (" << count << ") from endpoint '" << fromEndpointName @@ -617,7 +618,7 @@ void ApiListener::TryActivateZonesStageCallback(const ProcessResult& pr, * * @param relativePaths Required for later file operations in the callback. Provides the zone name plus path in a list. */ -void ApiListener::AsyncTryActivateZonesStage(const std::vector& relativePaths) +void ApiListener::AsyncTryActivateZonesStage(const std::vector& relativePaths, const Shared::Ptr& lock) { VERIFY(Application::GetArgC() >= 1); @@ -643,7 +644,10 @@ void ApiListener::AsyncTryActivateZonesStage(const std::vector& relative Process::Ptr process = new Process(Process::PrepareCommand(args)); process->SetTimeout(Application::GetReloadTimeout()); - process->Run(std::bind(&TryActivateZonesStageCallback, _1, relativePaths)); + + process->Run([relativePaths, lock](const ProcessResult& pr) { + TryActivateZonesStageCallback(pr, relativePaths); + }); } /** diff --git a/lib/remote/apilistener.hpp b/lib/remote/apilistener.hpp index b0b5b83f4..4a3623a68 100644 --- a/lib/remote/apilistener.hpp +++ b/lib/remote/apilistener.hpp @@ -200,7 +200,7 @@ private: static void TryActivateZonesStageCallback(const ProcessResult& pr, const std::vector& relativePaths); - static void AsyncTryActivateZonesStage(const std::vector& relativePaths); + static void AsyncTryActivateZonesStage(const std::vector& relativePaths, const Shared::Ptr& lock); static String GetChecksum(const String& content); static bool CheckConfigChange(const ConfigDirInformation& oldConfig, const ConfigDirInformation& newConfig);