From 411d03ac6b8ee1a8c06f952b9378c90516a715b7 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 20 Apr 2018 12:29:24 +0200 Subject: ThreadsafeQueue: add wakeup event instead of custom termination markers This avoids the issue that the ~SDR termination marker doesn't reach the consumer because it's still prebuffering --- src/Log.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Log.cpp') diff --git a/src/Log.cpp b/src/Log.cpp index ee16880..81f7955 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -82,15 +82,15 @@ void Logger::io_process() set_thread_name("logger"); while (1) { log_message_t m; - m_message_queue.wait_and_pop(m); - - auto message = m.message; - - if (m.level == trace and m.message.empty()) { - // Special message to stop thread + try { + m_message_queue.wait_and_pop(m); + } + catch (const ThreadsafeQueueWakeup&) { break; } + auto message = m.message; + /* Remove a potential trailing newline. * It doesn't look good in syslog */ -- cgit v1.2.3