1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

core/mbox: fix race condition

The mbox code contains a race condition in `mbox_put()`: When it
waits for a slot in the queue to become available, it is woken up with
IRQs enabled. It disables IRQs again as first thing, but by then
another thread may already have preempted the running thread and filled
the queue back up. In this case, a message in the queue would be
silently overwritten.
This commit is contained in:
Marian Buschsieweke 2022-11-22 22:35:13 +01:00
parent 54b0100c44
commit 42b9334784
No known key found for this signature in database
GPG Key ID: CB8E3238CE715A94

View File

@ -73,7 +73,7 @@ int _mbox_put(mbox_t *mbox, msg_t *msg, int blocking)
return 1;
}
else {
if (cib_full(&mbox->cib)) {
while (cib_full(&mbox->cib)) {
if (blocking) {
_wait(&mbox->writers, irqstate);
irqstate = irq_disable();