Skip to content

Commit

Permalink
Merge pull request #51 from gojek/fix/data_race_condition_reachability
Browse files Browse the repository at this point in the history
Fixed Data race condition in Network Reachability
  • Loading branch information
rcrahul43 authored Feb 21, 2024
2 parents e2546b2 + 497b73a commit 68b1eea
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ final class DefaultRetryMechanism: Retryable {
self.persistence = persistence
self.keepAliveService = keepAliveService

self.observeNetworkConnectivity()
self.establishConnection()
self.observeDeviceStatus()
self.observeAppStateChanges()
self.observeNetworkConnectivity()
self.keepConnectionAlive()
}

Expand All @@ -132,7 +132,6 @@ final class DefaultRetryMechanism: Retryable {

private func observeNetworkConnectivity() {
do {
try reachability.startNotifier()
reachability.whenReachable = { [weak self] (_) in
guard let checkedSelf = self else { return }
checkedSelf.establishConnection()
Expand All @@ -141,6 +140,7 @@ final class DefaultRetryMechanism: Retryable {
guard let checkedSelf = self else { return }
checkedSelf.terminateConnection()
}
try reachability.startNotifier()
} catch {
print("Unable to start notifier")
}
Expand Down

0 comments on commit 68b1eea

Please sign in to comment.