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