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.";