Skip to content

Commit

Permalink
Fix crash when recreating minimal connections (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianfett authored May 30, 2024
1 parent d379584 commit ee669e9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ extension PoolStateMachine {

let newConnectionRequest: ConnectionRequest?
if self.connections.count < self.minimumConcurrentConnections {
newConnectionRequest = .init(connectionID: self.generator.next())
newConnectionRequest = self.createNewConnection()
} else {
newConnectionRequest = .none
}
Expand Down
4 changes: 4 additions & 0 deletions Tests/ConnectionPoolModuleTests/PoolStateMachineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ final class PoolStateMachineTests: XCTestCase {
let connectionClosed = stateMachine.connectionClosed(connection)
XCTAssertEqual(connectionClosed.connection, .makeConnection(.init(connectionID: 1), []))
connection.closeIfClosing()
let establishAction = stateMachine.connectionEstablished(.init(id: 1), maxStreams: 1)
XCTAssertEqual(establishAction.request, .none)
guard case .scheduleTimers(let timers) = establishAction.connection else { return XCTFail("Unexpected connection action") }
XCTAssertEqual(timers, [.init(.init(timerID: 0, connectionID: 1, usecase: .keepAlive), duration: configuration.keepAliveDuration!)])
}

}

0 comments on commit ee669e9

Please sign in to comment.