From 74b65f1642c5642752d71185aad0a75bbf0c966e Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Mon, 16 Nov 2020 17:10:57 +0100 Subject: [PATCH] API filesync: wait for validation process to exit This avoid having to pass a lock implictly using the captured variables of a lambda. --- lib/remote/apilistener-filesync.cpp | 10 +++++----- lib/remote/apilistener.hpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/remote/apilistener-filesync.cpp b/lib/remote/apilistener-filesync.cpp index 9f48b1d25..2ab42870e 100644 --- a/lib/remote/apilistener-filesync.cpp +++ b/lib/remote/apilistener-filesync.cpp @@ -538,7 +538,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, lock); + AsyncTryActivateZonesStage(relativePaths); } else { Log(LogInformation, "ApiListener") << "Received configuration updates (" << count << ") from endpoint '" << fromEndpointName @@ -628,7 +628,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, const Shared>::Ptr& lock) +void ApiListener::AsyncTryActivateZonesStage(const std::vector& relativePaths) { VERIFY(Application::GetArgC() >= 1); @@ -655,9 +655,9 @@ void ApiListener::AsyncTryActivateZonesStage(const std::vector& relative Process::Ptr process = new Process(Process::PrepareCommand(args)); process->SetTimeout(Application::GetReloadTimeout()); - process->Run([relativePaths, lock](const ProcessResult& pr) { - TryActivateZonesStageCallback(pr, relativePaths); - }); + process->Run(); + const ProcessResult& pr = process->WaitForResult(); + TryActivateZonesStageCallback(pr, relativePaths); } /** diff --git a/lib/remote/apilistener.hpp b/lib/remote/apilistener.hpp index be1a0d506..41993bebb 100644 --- a/lib/remote/apilistener.hpp +++ b/lib/remote/apilistener.hpp @@ -202,7 +202,7 @@ private: static void TryActivateZonesStageCallback(const ProcessResult& pr, const std::vector& relativePaths); - static void AsyncTryActivateZonesStage(const std::vector& relativePaths, const Shared>::Ptr& lock); + static void AsyncTryActivateZonesStage(const std::vector& relativePaths); static String GetChecksum(const String& content); static bool CheckConfigChange(const ConfigDirInformation& oldConfig, const ConfigDirInformation& newConfig);