API filesync: wait for validation process to exit

This avoid having to pass a lock implictly using the captured variables
of a lambda.
This commit is contained in:
Julian Brost 2020-11-16 17:10:57 +01:00
parent 4c8c4c75ec
commit 74b65f1642
2 changed files with 6 additions and 6 deletions

View File

@ -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<String>& relativePaths, const Shared<std::unique_lock<SpinLock>>::Ptr& lock)
void ApiListener::AsyncTryActivateZonesStage(const std::vector<String>& relativePaths)
{
VERIFY(Application::GetArgC() >= 1);
@ -655,9 +655,9 @@ void ApiListener::AsyncTryActivateZonesStage(const std::vector<String>& 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);
}
/**

View File

@ -202,7 +202,7 @@ private:
static void TryActivateZonesStageCallback(const ProcessResult& pr,
const std::vector<String>& relativePaths);
static void AsyncTryActivateZonesStage(const std::vector<String>& relativePaths, const Shared<std::unique_lock<SpinLock>>::Ptr& lock);
static void AsyncTryActivateZonesStage(const std::vector<String>& relativePaths);
static String GetChecksum(const String& content);
static bool CheckConfigChange(const ConfigDirInformation& oldConfig, const ConfigDirInformation& newConfig);