diff --git a/src/lib/ipc/IpcLogOutputter.cpp b/src/lib/ipc/IpcLogOutputter.cpp index 3f60e215..c718340c 100644 --- a/src/lib/ipc/IpcLogOutputter.cpp +++ b/src/lib/ipc/IpcLogOutputter.cpp @@ -116,7 +116,12 @@ void IpcLogOutputter::appendBuffer(const String& text) { ArchMutexLock lock(m_bufferMutex); - m_buffer.push(text); + if (m_buffer.size() >= m_bufferMaxSize) { + // if the queue is exceeds size limit, + // throw away the oldest item + m_buffer.pop_front(); + } + m_buffer.push_back(text); } void @@ -182,7 +187,7 @@ IpcLogOutputter::getChunk(size_t count) for (size_t i = 0; i < count; i++) { chunk.append(m_buffer.front()); chunk.append("\n"); - m_buffer.pop(); + m_buffer.pop_front(); } return chunk; } diff --git a/src/lib/ipc/IpcLogOutputter.h b/src/lib/ipc/IpcLogOutputter.h index b585b254..463e19c8 100644 --- a/src/lib/ipc/IpcLogOutputter.h +++ b/src/lib/ipc/IpcLogOutputter.h @@ -22,7 +22,7 @@ #include "arch/IArchMultithread.h" #include "base/ILogOutputter.h" -#include +#include class IpcServer; class Event; @@ -87,7 +87,7 @@ private: void appendBuffer(const String& text); private: - typedef std::queue Buffer; + typedef std::deque Buffer; IpcServer& m_ipcServer; Buffer m_buffer;