1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2026-01-01 01:41:18 +01:00

sock_async_event: fix race-condition

If a new event is fired during the execution of the event callback,
`event->type` might change. However as `event->type` is set to 0 after
the execution of the callback, that leads to it being 0 on the next
round of the event handler's execution, leading in the event getting
lost.
This commit is contained in:
Martine Lenders 2020-02-21 15:50:30 +01:00
parent ea24d30e7a
commit d26355fbb4

View File

@ -13,14 +13,20 @@
* @author Martine Lenders <m.lenders@fu-berlin.de>
*/
#include "irq.h"
#include "net/sock/async/event.h"
static void _event_handler(event_t *ev)
{
sock_event_t *event = (sock_event_t *)ev;
unsigned state = irq_disable();
sock_async_flags_t _type = event->type;
event->cb.generic(event->sock, event->type);
event->type = 0;
irq_restore(state);
if (_type) {
event->cb.generic(event->sock, _type);
}
}
static inline void _cb(void *sock, sock_async_flags_t type,