From 5be1fd0cfabb8e737ad8fe9c2036ae3daf419ce8 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Tue, 10 Jul 2012 10:04:52 +0000 Subject: [PATCH] made ipc log outputter message drop mechanism only drop messages from the buffer thread (*should* not cause deadlock, but feels a bit risky). --- src/lib/ipc/CIpcLogOutputter.cpp | 7 ++++++- src/lib/ipc/CIpcLogOutputter.h | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/ipc/CIpcLogOutputter.cpp b/src/lib/ipc/CIpcLogOutputter.cpp index e958772b..477d1e72 100644 --- a/src/lib/ipc/CIpcLogOutputter.cpp +++ b/src/lib/ipc/CIpcLogOutputter.cpp @@ -89,7 +89,11 @@ CIpcLogOutputter::write(ELevel, const char* text, bool force) // would be difficult to distinguish (other than looking at the stack // trace somehow). perhaps a file stream might be a better option :-/ if (m_sending && !force) { - return true; + + // ignore events from the buffer thread (would cause recursion). + if (CThread::getCurrentThread().getID() == m_bufferThreadId) { + return true; + } } appendBuffer(text); @@ -107,6 +111,7 @@ CIpcLogOutputter::appendBuffer(const CString& text) void CIpcLogOutputter::bufferThread(void*) { + m_bufferThreadId = m_bufferThread->getID(); try { while (m_running) { diff --git a/src/lib/ipc/CIpcLogOutputter.h b/src/lib/ipc/CIpcLogOutputter.h index 4db8c281..284e815b 100644 --- a/src/lib/ipc/CIpcLogOutputter.h +++ b/src/lib/ipc/CIpcLogOutputter.h @@ -20,6 +20,7 @@ #include "ILogOutputter.h" #include "CArch.h" #include +#include "IArchMultithread.h" class CIpcServer; class CEvent; @@ -64,4 +65,6 @@ private: CArchCond m_notifyCond; CArchMutex m_notifyMutex; bool m_bufferWaiting; + IArchMultithread::ThreadID + m_bufferThreadId; };