Skip to content

Commit

Permalink
logging: fix log buffer pending while it is definitely full
Browse files Browse the repository at this point in the history
The buffer flags MPSC_PBUF_FULL is a shared resource to determine
whether the buffer is available. When processing drop messages,
the flag will be cleared first and then set, add spin lock protection.

Signed-off-by: Xiaolu Sun <xiaolu.sun@intel.com>
  • Loading branch information
xiaolusu committed Aug 15, 2024
1 parent 37ffa07 commit 383ae68
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/os/mpsc_pbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,10 @@ void mpsc_pbuf_free(struct mpsc_pbuf_buffer *buffer,
bool mpsc_pbuf_is_pending(struct mpsc_pbuf_buffer *buffer)
{
uint32_t a;
k_spinlock_key_t key = k_spin_lock(&buffer->lock);

(void)available(buffer, &a);
k_spin_unlock(&buffer->lock, key);

return a ? true : false;
}
Expand Down

0 comments on commit 383ae68

Please sign in to comment.