Skip to content

Commit

Permalink
Fixed a data race that occasionally causes a crash if webSocketTransp…
Browse files Browse the repository at this point in the history
…ort.closeConnection() and webSocketTransport.initServer() are called in succession. Fix was verified with Xcode Thread sanitizer
  • Loading branch information
Seppo Tomperi committed Apr 1, 2021
1 parent e2be065 commit a45e61c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Sources/ApolloWebSocket/WebSocketTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,13 @@ public class WebSocketTransport {
}

public func initServer() {
self.acked = false
processingQueue.async {
self.acked = false

if let str = OperationMessage(payload: self.connectingPayload, type: .connectionInit).rawMessage {
write(str, force:true)
if let str = OperationMessage(payload: self.connectingPayload, type: .connectionInit).rawMessage {
write(str, force:true)
}
}

}

public func closeConnection() {
Expand Down

0 comments on commit a45e61c

Please sign in to comment.