fix(s2n-quic-dc): synchronize dispatch queue closure #2553
Merged
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.
Description of changes:
After doing some testing, the current dispatch queue closing logic has a potential race condition where the queue can end up being freed twice. This change fixes that by locking both receivers in the same order (to avoid a deadlock) and observing the other side's status before deciding to free the queue or not.
Call-outs:
I did a little more clean up around tracing events by creating actual probes instead. I've also tried to avoid calling any of the probes while holding a mutex.
Testing:
I added a stress test that was able to reproduce the original issue and show that the changes fixed.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.