Please sign in to comment.
subsys: logging: fix trigger threshold corner case
The CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD option can be used to wake up the background log processing thread when a given number of messages have been queued. Currently, the msg_finalize() routine which is responsible for queueing a log message for later handling appends messages to the global list after performing the threshold check and waking up the thread. This leads to a race condition with undesirable behavior if the threshold == 1: - the msg_finalize() thread is scheduled out by calling k_wakeup() - the log processing thread wakes up, notice that no messages are queued, and goes back to sleep - the msg_finalize() thread is scheduled back in and the message is queued for processing This defers the handling of the message until the processing thread wakes up again after the CONFIG_LOG_PROCESS_THREAD_SLEEP_MS timeout, which is not what the user wants. Fix this by queueing the message before waking up the handler thread. (This also may improve responsiveness for larger threshold values.) Signed-off-by: Marti Bolivar <email@example.com>
- Loading branch information...