Skip to content

Commit

Permalink
Merge pull request #9853 from Icinga/GelfWriter-m_StreamMutex
Browse files Browse the repository at this point in the history
GelfWriter: protect m_Stream via m_WorkQueue, not ObjectLock(this)
  • Loading branch information
julianbrost authored Sep 7, 2023
2 parents 65dab46 + 4ee10a6 commit bba6a76
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions lib/perfdata/gelfwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<GelfWriter>::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.";
Expand Down Expand Up @@ -513,8 +512,6 @@ void GelfWriter::SendLogMessage(const Checkable::Ptr& checkable, const String& g

String log = msgbuf.str();

ObjectLock olock(this);

if (!GetConnected())
return;

Expand Down

0 comments on commit bba6a76

Please sign in to comment.