From 582e289e5a9c77ee3c4944acab6aa1386fa9956d Mon Sep 17 00:00:00 2001 From: Sebastian Villena <97059974+ruisebas@users.noreply.github.com> Date: Tue, 10 Dec 2024 15:21:50 -0500 Subject: [PATCH] fix(IoT): Fixing a race condition when invalidating/creating the reconnect timer (#5454) --- AWSIoT/Internal/AWSIoTMQTTClient.m | 13 ++++++++++--- CHANGELOG.md | 5 ++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/AWSIoT/Internal/AWSIoTMQTTClient.m b/AWSIoT/Internal/AWSIoTMQTTClient.m index 010a2df956f..96df6717e36 100644 --- a/AWSIoT/Internal/AWSIoTMQTTClient.m +++ b/AWSIoT/Internal/AWSIoTMQTTClient.m @@ -690,12 +690,19 @@ - (void)cleanupReconnectTimer { waitUntilDone:NO]; return; } - - [self.reconnectTimer invalidate]; - self.reconnectTimer = nil; + + [self invalidateReconnectTimer]; } } +- (void)invalidateReconnectTimer { + __weak AWSIoTMQTTClient *weakSelf = self; + dispatch_async(self.timerQueue, ^{ + [weakSelf.reconnectTimer invalidate]; + weakSelf.reconnectTimer = nil; + }); +} + - (void)cleanUpWebsocketOutputStream { @synchronized(self) { if (self.websocketOutputStream) { diff --git a/CHANGELOG.md b/CHANGELOG.md index d3cd754a609..3ac61be687e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,10 @@ ## Unreleased --Features for next release +### Bug Fixes + +- **AWSIoT** + - Fixing a race condition when invalidating/creating the reconnect timer (#5454) ## 2.38.0