-
Notifications
You must be signed in to change notification settings - Fork 891
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
fix(Core): Fixing concurrency issues in AWSSynchronizedMutableDictionary
#5413
Merged
Conversation
This file contains 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
fix(IoT): Fixing random crash when a connection is attempted just after disconnecting
sebaland
had a problem deploying
to
IntegrationTest
July 31, 2024 16:40 — with
GitHub Actions
Failure
5d
approved these changes
Jul 31, 2024
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.
Issue #, if available:
Description of changes:
When using barriers and concurrent queues, doing
dispatch_barrier_sync
can cause deadlocks (and crashes), sodispatch_barrier_async
is recommended.Our
AWSSynchronizedMutableDictionary
was using sync for write operations, which are really unnecessary and can be async. Read operations do remainsync
, but with no barrier involved.Also included in this PR is a potential fix for the random crash when disconnecting and quickly connecting again. If a disconnection happens due to an error, the
reconnectThread
is trigger, which sets thereconnectTimer
so that a reconnection is attempted in x seconds.But if a new connection is explicitly triggered, a new
streamsThread
will be created and the old one discarded. We do attempt to invalidate thereconnectTimer
in these situations, but we try to do it in thereconnectThread
as that is where the timer was set.However, if the
reconnectThread
has finished (i.e. not running), then the timer will not be invalidated and will fire eventually, which will attempt to use the now deallocated oldstreamsThread
.So I'm just adding a simple check to allow us to invalidate the timer anyway if the
reconnectThread
has finished.Check points:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.