diff --git a/lib/perfdata/elasticsearchwriter.cpp b/lib/perfdata/elasticsearchwriter.cpp index 09ef31615d3..9c8f52e60a7 100644 --- a/lib/perfdata/elasticsearchwriter.cpp +++ b/lib/perfdata/elasticsearchwriter.cpp @@ -118,10 +118,12 @@ void ElasticsearchWriter::Pause() m_HandleNotifications.disconnect(); m_FlushTimer->Stop(true); - - Flush(); m_WorkQueue.Join(); - Flush(); + + { + std::unique_lock lock (m_DataBufferMutex); + Flush(); + } Log(LogInformation, "ElasticsearchWriter") << "'" << GetName() << "' paused.";