From 076eb594437c2e5bc03b8d98913f5b175e2b7640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Aleksandrovi=C4=8D=20Klimov?= Date: Fri, 30 Jun 2023 14:57:18 +0200 Subject: [PATCH] ElasticsearchWriter#Pause(): lock m_DataBufferMutex during Flush() just to be sure regarding race conditions. --- lib/perfdata/elasticsearchwriter.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/perfdata/elasticsearchwriter.cpp b/lib/perfdata/elasticsearchwriter.cpp index 79b522768..9c8f52e60 100644 --- a/lib/perfdata/elasticsearchwriter.cpp +++ b/lib/perfdata/elasticsearchwriter.cpp @@ -119,7 +119,11 @@ void ElasticsearchWriter::Pause() m_FlushTimer->Stop(true); m_WorkQueue.Join(); - Flush(); + + { + std::unique_lock lock (m_DataBufferMutex); + Flush(); + } Log(LogInformation, "ElasticsearchWriter") << "'" << GetName() << "' paused.";