Skip to content

Commit

Permalink
Fixed locking on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr. Brandon Wiley committed Jan 21, 2021
1 parent 4bdc459 commit fc1cfae
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Sources/Transmission/Connection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public class Connection
self.connectLock.leave()
return
case .cancelled:
self.connectLock.leave()
self.failConnect()
return
case .failed(_):
self.connectLock.leave()
self.failConnect()
return
case .waiting(let error):
self.connectLock.leave()
case .waiting(_):
self.failConnect()
return
default:
return
Expand All @@ -64,6 +64,13 @@ public class Connection

guard success else {return nil}
}

func failConnect()
{
self.connection.stateUpdateHandler = nil
self.connection.cancel()
self.connectLock.leave()
}

public func read(size: Int) -> Data?
{
Expand Down

0 comments on commit fc1cfae

Please sign in to comment.