diff --git a/lib/perfdata/gelfwriter.cpp b/lib/perfdata/gelfwriter.cpp index 79e76aaa3a3..c5b2bbd132e 100644 --- a/lib/perfdata/gelfwriter.cpp +++ b/lib/perfdata/gelfwriter.cpp @@ -114,18 +114,17 @@ void GelfWriter::Pause() m_ReconnectTimer->Stop(true); - try { - ReconnectInternal(); - } catch (const std::exception&) { - Log(LogInformation, "GelfWriter") - << "'" << GetName() << "' paused. Unable to connect, not flushing buffers. Data may be lost on reload."; - - ObjectImpl::Pause(); - return; - } + m_WorkQueue.Enqueue([this]() { + try { + ReconnectInternal(); + } catch (const std::exception&) { + Log(LogInformation, "GelfWriter") + << "Unable to connect, not flushing buffers. Data may be lost."; + } + }, PriorityImmediate); + m_WorkQueue.Enqueue([this]() { DisconnectInternal(); }, PriorityLow); m_WorkQueue.Join(); - DisconnectInternal(); Log(LogInformation, "GelfWriter") << "'" << GetName() << "' paused."; @@ -513,8 +512,6 @@ void GelfWriter::SendLogMessage(const Checkable::Ptr& checkable, const String& g String log = msgbuf.str(); - ObjectLock olock(this); - if (!GetConnected()) return;