[riot-notifications] [RIOT-OS/RIOT] sys/event: Clear event thread flag when get returns an event (#11020)
notifications at github.com
Fri Feb 15 12:09:45 CET 2019
### Contribution description
The [event module](http://doc.riot-os.org/group__sys__event.html) provides two ways of retrieving an event directly from an event queue: `event_get` (non-blocking) and `event_wait` (blocking).
`event_wait` makes use of thread flags to block the waiting thread, every time an event is posted to the queue the `THREAD_FLAG_EVENT` flag is set. Right now, if `event_get` is called the event is removed from the queue but the thread flag is not clear, so the next call to `event_wait` will return immediately and if no event has been posted since the call to `event_get` it will return (and try to modify the event pointed by) a NULL pointer.
### Testing procedure
A test to probe this situation has been added to `tests/events`. So by running the test on commit `8dab9e4c64a5e3226b3f1c1d505a2c280b0f174c` it should fail, and after applying `5eb6fba1baedbdf6ccbbe0a65c0b2418cfd85110` it should work.
### Issues/PRs references
You can view, comment on, or merge this pull request online at:
-- Commit Summary --
* sys/event: Clear event flag on get
* tests/events: Test wait after get event
-- File Changes --
M sys/event/event.c (5)
M tests/events/main.c (33)
-- Patch Links --
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the notifications