-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sys/suit: Ensure previous thread is stopped before reusing its stack #19199
sys/suit: Ensure previous thread is stopped before reusing its stack #19199
Conversation
I wonder a bit: |
That too would be a completely fine solution. There'd probably be a mutex and some other mechanism (a second mutex, an thread flag, whatever), but yes, chances are it's simpler. It may make me come back to matrix and ask "are there now any valid use cases for a thread terminating and restarting?", but that's not really a concern for this concrete issue. |
Thinking about it, one reason to do it that way was that if you don't call The suit thread is only needed because the So if you already have a thread with sufficient stack you would call |
bors merge |
Build succeeded: |
Contribution description
Closes: #19195
If the thread has released the mutex but the thread has not terminated (which happens in the situation that would previously have overwritten a still active thread's state), then a warning is shown and the trigger is ignored.
Testing procedure
This should work before and after:
make -C examples/suit_update BOARD=native all term
aiocoap-client coap://'[fe80::3c63:beff:fe85:ca96%tapbr0]'/suit/trigger -m POST --payload 'coap://[2001:db8::]/foo'
suit fetch coap://[2001:db8::]/foo
Run again with the worker thread on low priority:
Before, this runs the download once silently (no clue why it doesn't run it twice, but then again, I claim there's concurrent memory access from two thread, so who knows what happens). After, it runs a single download and shows an error message for the second one once the first is complete ("Ignoring SUIT trigger: worker is still busy.").
Issues/PRs references
This may be made incrementally easier by #19197 -- that PR as it is now would spare us the zombification (because returning would do that), and having a
wait
function would allow us to turn the new error case into a success.