made ipc log outputter message drop mechanism only drop messages from the buffer thread (*should* not cause deadlock, but feels a bit risky).

This commit is contained in:
Nick Bolton 2012-07-10 10:04:52 +00:00
parent 8bad45e8a2
commit 5be1fd0cfa
2 changed files with 9 additions and 1 deletions

View File

@ -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) {

View File

@ -20,6 +20,7 @@
#include "ILogOutputter.h"
#include "CArch.h"
#include <queue>
#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;
};