sys/ztimer: implement ztimer_mbox_get_timeout() and use it to fix race in gnrc_sock_recv()#21113
Merged
maribu merged 3 commits intoRIOT-OS:masterfrom Jan 10, 2025
Merged
Conversation
This function fetches a message from an mbox, possibly blocking if the mbox has no message - but with a specified timeout.
This was referenced Dec 31, 2024
aff3a6a to
97e862c
Compare
97e862c to
a1fd9e3
Compare
Member
Author
|
Fixed a typo found by codespell and squashed |
benpicco
approved these changes
Jan 10, 2025
Contributor
benpicco
left a comment
There was a problem hiding this comment.
That's a much cleaner solution than what has been there before.
Contributor
|
Uh the provided test fails on CI |
Implement the timeout using ztimer_mbox_get_timeout() to fix a race condition.
a1fd9e3 to
56ea5cd
Compare
Member
Author
|
Let's try again with even more relaxed timeout on |
Member
Author
|
Thx! |
maribu
added a commit
to maribu/RIOT
that referenced
this pull request
Jan 10, 2025
This reverts commit e3d0068, which added a work around for two bugs: - ztimer triggering too early (fixed in RIOT-OS#20924) - gnrc_sock_recv() returning when an old "timeout" message is still in the message queue (fixed in RIOT-OS#21113) With those bugs fixed, the work around should not longer be needed.
Member
Author
The test is flaky on |
dprigoshij
pushed a commit
to dprigoshij/RIOT
that referenced
this pull request
Mar 24, 2025
This reverts commit e3d0068, which added a work around for two bugs: - ztimer triggering too early (fixed in RIOT-OS#20924) - gnrc_sock_recv() returning when an old "timeout" message is still in the message queue (fixed in RIOT-OS#21113) With those bugs fixed, the work around should not longer be needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contribution description
This implements
ztimer_mbox_get_timeout()and salvages the test app from #18977 with minor tweaking.On top of
ztimer_mbox_get_timeout(), the timeout ofgnrc_sock_recv()is now implemented race-free.Testing procedure
Run the provided test app. (Maybe also set
ENABLE_DEBUGto1insys/ztimer/utils.cto ensure that the race when a message was received just in time but the timeout was not cancelled in time is indeed triggered by the test app.)Also do some testing with GNRC's SOCK implementation and proper timeout handling.
Issues/PRs references
Better alternative to #18977