-
Notifications
You must be signed in to change notification settings - Fork 886
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(IoT): Fixing race conditions during cleanup in AWSIoTStreamThread
#5477
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
…5452 Related issue: #5452 Description of changes: 1. Addition of Synchronization Primitives New Properties: - dispatch_queue_t cleanupQueue - dispatch_semaphore_t cleanupSemaphore - BOOL isCleaningUp Purpose: Ensures thread-safe access and modification of critical properties like isRunning, shouldDisconnect, and defaultRunLoopTimer. Synchronization prevents race conditions during cleanup and cancellation processes. 2. Enhanced shouldContinueRunning Method Before: Used direct property access without synchronization After: Introduced synchronization using dispatch_sync for thread-safe checks Purpose:Prevents inconsistencies if multiple threads attempt to read/write properties simultaneously. 3. Cleanup Enhancements performCleanup and cleanupResources: Added explicit synchronization: dispatch_sync and dispatch_semaphore ensure cleanup operations are thread-safe and do not overlap if called multiple times. Handles complex cleanup sequences safely, such as invalidating timers, disconnecting streams, and deallocating the session. Purpose: Ensures that cleanup actions (e.g., closing streams and invalidating timers) are thread-safe and only executed once. 4. Timer Initialization Weak Reference to Prevent Retain Cycles: The timer in setupRunLoop now uses a __weak reference to avoid retain cycles Before: Used a strong reference (target:self), which could result in a retain cycle. Purpose: Avoids potential memory leaks by ensuring the thread does not retain itself via the timer. 5. Improved cancel Method Before: Simple isRunning flag and direct super cancel call After: Introduced thread-safe handling and ensured timer invalidation Purpose: Prevents race conditions when canceling the thread, ensuring timers are invalidated and properties are safely updated.
ruisebas
had a problem deploying
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Failure
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
had a problem deploying
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Failure
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 18:53 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 19:49 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 19:49 — with
GitHub Actions
Inactive
ruisebas
force-pushed
the
ruisebas/streamthread-safe
branch
from
December 13, 2024 20:43
3077ea4
to
580e1e6
Compare
ruisebas
had a problem deploying
to
IntegrationTest
December 13, 2024 21:54 — with
GitHub Actions
Failure
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:54 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:54 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:54 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:54 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:54 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:54 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:54 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:54 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:54 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:54 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:54 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:55 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:55 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:55 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:55 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:55 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:55 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:55 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:55 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:55 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:55 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:55 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:55 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 13, 2024 21:55 — with
GitHub Actions
Inactive
ruisebas
temporarily deployed
to
IntegrationTest
December 16, 2024 19:51 — with
GitHub Actions
Inactive
5 tasks
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:
This PR works on top of #5469 to address the issues that caused the unit tests to crash/fail.
The overall changes include:
Check points:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.