Skip to content
Commit 802156c0 authored by Luca Burelli's avatar Luca Burelli Committed by Benjamin Cabé
Browse files

logging: improve log_flush() robustness



The 'log_flush()' function is used to wait for all pending log messages
to be processed by the background thread. This is performed by polling
the 'log_data_pending()' function, which scans all available buffers.

The log core already provides a 'buffered_cnt' variable that keeps track
of the number of pending messages. This variable is updated atomically
and could be a more efficient implementation for that check.

This commit moves the 'buffered_cnt' decrement _after_ the message
processing and buffer release, to ensure that the variable reflects
the number of pending messages at any moment in time.

The 'log_data_pending()' function is then replaced with a direct check
of the 'buffered_cnt' variable.

Signed-off-by: default avatarLuca Burelli <l.burelli@arduino.cc>
parent dba0947c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment