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; } }