mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +02:00
GelfWriter: protect m_Stream via m_WorkQueue, not ObjectLock(this)
On shutdown or HA re-connect ConfigObject#SetAuthority(false) is called which does ObjectLock(this) and ConfigObject#Pause(). GelfWriter#Pause(), with the above ObjectLock, calls m_WorkQueue.Join(). But items inside that also doing ObjectLock(this) cause a deadlock.
This commit is contained in:
parent
85c5a7c901
commit
fecb209fe0
@ -114,18 +114,17 @@ void GelfWriter::Pause()
|
|||||||
|
|
||||||
m_ReconnectTimer->Stop(true);
|
m_ReconnectTimer->Stop(true);
|
||||||
|
|
||||||
try {
|
m_WorkQueue.Enqueue([this]() {
|
||||||
ReconnectInternal();
|
try {
|
||||||
} catch (const std::exception&) {
|
ReconnectInternal();
|
||||||
Log(LogInformation, "GelfWriter")
|
} catch (const std::exception&) {
|
||||||
<< "'" << GetName() << "' paused. Unable to connect, not flushing buffers. Data may be lost on reload.";
|
Log(LogInformation, "GelfWriter")
|
||||||
|
<< "Unable to connect, not flushing buffers. Data may be lost.";
|
||||||
ObjectImpl<GelfWriter>::Pause();
|
}
|
||||||
return;
|
}, PriorityImmediate);
|
||||||
}
|
|
||||||
|
|
||||||
|
m_WorkQueue.Enqueue([this]() { DisconnectInternal(); }, PriorityLow);
|
||||||
m_WorkQueue.Join();
|
m_WorkQueue.Join();
|
||||||
DisconnectInternal();
|
|
||||||
|
|
||||||
Log(LogInformation, "GelfWriter")
|
Log(LogInformation, "GelfWriter")
|
||||||
<< "'" << GetName() << "' paused.";
|
<< "'" << GetName() << "' paused.";
|
||||||
@ -513,8 +512,6 @@ void GelfWriter::SendLogMessage(const Checkable::Ptr& checkable, const String& g
|
|||||||
|
|
||||||
String log = msgbuf.str();
|
String log = msgbuf.str();
|
||||||
|
|
||||||
ObjectLock olock(this);
|
|
||||||
|
|
||||||
if (!GetConnected())
|
if (!GetConnected())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user