Skip to content

Commit fa7513c

Browse files
gh-action-runnergh-action-runner
authored andcommitted
Squashed 'apollo-ios/' changes from 51e535dc..69f09c7a
69f09c7a Fix potential data race (#636) git-subtree-dir: apollo-ios git-subtree-split: 69f09c7aa866bdddfcdf4f8da8c5cc35f1a44626
1 parent 15b6291 commit fa7513c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Sources/ApolloWebSocket/WebSocketTransport.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class WebSocketTransport {
5151

5252
@Atomic
5353
private var subscribers = [String: (Result<JSONObject, any Error>) -> Void]()
54+
@Atomic
5455
private var subscriptions : [String: String] = [:]
5556
let processingQueue = DispatchQueue(label: "com.apollographql.WebSocketTransport")
5657

@@ -307,7 +308,7 @@ public class WebSocketTransport {
307308
}
308309

309310
self.queue.removeAll()
310-
self.subscriptions.removeAll()
311+
self.$subscriptions.mutate { $0.removeAll() }
311312
}
312313
}
313314

@@ -356,7 +357,7 @@ public class WebSocketTransport {
356357

357358
self.$subscribers.mutate { $0[identifier] = resultHandler }
358359
if Operation.operationType == .subscription {
359-
self.subscriptions[identifier] = message
360+
self.$subscriptions.mutate { $0[identifier] = message }
360361
}
361362
}
362363

@@ -377,7 +378,7 @@ public class WebSocketTransport {
377378
self.write(str)
378379
}
379380
self.$subscribers.mutate { $0.removeValue(forKey: subscriptionId) }
380-
self.subscriptions.removeValue(forKey: subscriptionId)
381+
self.$subscriptions.mutate { $0.removeValue(forKey: subscriptionId) }
381382
}
382383
}
383384

0 commit comments

Comments
 (0)