mavlink: lock sending messages outside #14673
Closed
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.
This is an attempt to prevent any of the 3 parts of a MAVLink message to end up on the buffer without the other parts. When partial messages end up on the buffer it will cause message drops because the parser reads too far and will miss the subsequent message.
By locking around the full process and preventing races between the message senders in the receiver thread and the actual sending threads we prevent message drops which e.g. leads to a cleaner initial param download.
This is an alternative to #12967. The param download works equally well, so 100% for the tested cases but CPU usage of the MAVLink threads is almost doubled, so this PR is clearly much worse.
I'm not sure why that's the case though it must have something to do with the locking.
For the test data, check: https://docs.google.com/spreadsheets/d/1aAT58x1zVd6_5bL9NjCOnc87Eoy4Aa3QMd-cmwZXI8A