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,8 +89,12 @@ CIpcLogOutputter::write(ELevel, const char* text, bool force)
// would be difficult to distinguish (other than looking at the stack // would be difficult to distinguish (other than looking at the stack
// trace somehow). perhaps a file stream might be a better option :-/ // trace somehow). perhaps a file stream might be a better option :-/
if (m_sending && !force) { if (m_sending && !force) {
// ignore events from the buffer thread (would cause recursion).
if (CThread::getCurrentThread().getID() == m_bufferThreadId) {
return true; return true;
} }
}
appendBuffer(text); appendBuffer(text);
notifyBuffer(); notifyBuffer();
@ -107,6 +111,7 @@ CIpcLogOutputter::appendBuffer(const CString& text)
void void
CIpcLogOutputter::bufferThread(void*) CIpcLogOutputter::bufferThread(void*)
{ {
m_bufferThreadId = m_bufferThread->getID();
try { try {
while (m_running) { while (m_running) {

View File

@ -20,6 +20,7 @@
#include "ILogOutputter.h" #include "ILogOutputter.h"
#include "CArch.h" #include "CArch.h"
#include <queue> #include <queue>
#include "IArchMultithread.h"
class CIpcServer; class CIpcServer;
class CEvent; class CEvent;
@ -64,4 +65,6 @@ private:
CArchCond m_notifyCond; CArchCond m_notifyCond;
CArchMutex m_notifyMutex; CArchMutex m_notifyMutex;
bool m_bufferWaiting; bool m_bufferWaiting;
IArchMultithread::ThreadID
m_bufferThreadId;
}; };