From b2e91401b73563492ee2e599a15b096094c28966 Mon Sep 17 00:00:00 2001 From: Bernhard Kirchen Date: Tue, 22 Jul 2025 21:18:31 +0200 Subject: [PATCH] logging: unlock while processing buffer allows high priority tasks to log another message while the buffer is being processed. --- src/MessageOutput.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/MessageOutput.cpp b/src/MessageOutput.cpp index b0519d13..1757eccf 100644 --- a/src/MessageOutput.cpp +++ b/src/MessageOutput.cpp @@ -200,7 +200,7 @@ void MessageOutputClass::send_ws_chunk(const uint8_t* buffer, size_t size) void MessageOutputClass::loop() { - std::lock_guard lock(_msgLock); + std::unique_lock lock(_msgLock); while (_buffer_out != _buffer_in) { uint8_t msg_len = static_cast(_buffer[_buffer_out]); @@ -212,11 +212,16 @@ void MessageOutputClass::loop() continue; } + lock.unlock(); + taskYIELD(); // allow high priority tasks to log while we process the buffer + auto msg_start = reinterpret_cast(&_buffer[_buffer_out]) + 1; serialWrite(msg_start, msg_len); Syslog.write(msg_start, msg_len); send_ws_chunk(msg_start, msg_len); + lock.lock(); + _buffer_out += 1 + msg_len; } }