Merge pull request #9853 from Icinga/GelfWriter-m_StreamMutex

GelfWriter: protect m_Stream via m_WorkQueue, not ObjectLock(this)
This commit is contained in:
Julian Brost 2023-09-07 11:46:38 +02:00 committed by GitHub
commit bba6a76f4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 12 deletions

View File

@ -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.";
@ -513,8 +512,6 @@ void GelfWriter::SendLogMessage(const Checkable::Ptr& checkable, const String& g
String log = msgbuf.str();
ObjectLock olock(this);
if (!GetConnected())
return;