Skip to content

Commit 45705a8

Browse files
xiaolusunashif
authored andcommitted
logging: fix log buffer pending while it is definitely full
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 <[email protected]>
1 parent f940534 commit 45705a8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/os/mpsc_pbuf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,10 @@ void mpsc_pbuf_free(struct mpsc_pbuf_buffer *buffer,
611611
bool mpsc_pbuf_is_pending(struct mpsc_pbuf_buffer *buffer)
612612
{
613613
uint32_t a;
614+
k_spinlock_key_t key = k_spin_lock(&buffer->lock);
614615

615616
(void)available(buffer, &a);
617+
k_spin_unlock(&buffer->lock, key);
616618

617619
return a ? true : false;
618620
}

0 commit comments

Comments
 (0)