@@ -57,7 +57,6 @@ extension HTTPConnectionPool {
57
57
case cleanupConnections( CleanupContext , isShutdown: IsShutdown )
58
58
case closeConnectionAndCreateConnection(
59
59
closeConnection: Connection ,
60
- isShutdown: IsShutdown ,
61
60
newConnectionID: Connection . ID ,
62
61
on: EventLoop
63
62
)
@@ -441,7 +440,6 @@ extension HTTPConnectionPool.StateMachine {
441
440
)
442
441
case closeConnectionAndCreateConnection(
443
442
closeConnection: HTTPConnectionPool . Connection ,
444
- isShutdown: HTTPConnectionPool . StateMachine . ConnectionAction . IsShutdown ,
445
443
newConnectionID: HTTPConnectionPool . Connection . ID ,
446
444
on: EventLoop
447
445
)
@@ -472,13 +470,11 @@ extension HTTPConnectionPool.StateMachine.ConnectionAction {
472
470
self = . closeConnection( connection, isShutdown: isShutdown)
473
471
case . closeConnectionAndCreateConnection(
474
472
let closeConnection,
475
- let isShutdown,
476
473
let newConnectionID,
477
474
let eventLoop
478
475
) :
479
476
self = . closeConnectionAndCreateConnection(
480
477
closeConnection: closeConnection,
481
- isShutdown: isShutdown,
482
478
newConnectionID: newConnectionID,
483
479
on: eventLoop
484
480
)
@@ -510,28 +506,14 @@ extension HTTPConnectionPool.StateMachine.ConnectionAction {
510
506
)
511
507
case . closeConnectionAndCreateConnection(
512
508
closeConnection: let connection,
513
- let isShutdown,
514
509
newConnectionID: _,
515
510
on: _
516
511
) :
517
512
// This event can only come _from_ the HTTP/1 pool, migrating to HTTP/2. We do not do prewarmed HTTP/2 connections,
518
513
// so we can ignore the request for a new connection. This is thus the same as the case below.
519
- fallthrough
514
+ return Self . closeConnection ( connection , isShutdown : . no , migrationAction : migrationAction )
520
515
case . closeConnection( let connection, let isShutdown) :
521
- guard isShutdown == . no else {
522
- precondition (
523
- migrationAction. closeConnections. isEmpty && migrationAction. createConnections. isEmpty,
524
- " migration actions are not supported during shutdown "
525
- )
526
- return . closeConnection( connection, isShutdown: isShutdown)
527
- }
528
- var closeConnections = migrationAction. closeConnections
529
- closeConnections. append ( connection)
530
- return . migration(
531
- createConnections: migrationAction. createConnections,
532
- closeConnections: closeConnections,
533
- scheduleTimeout: nil
534
- )
516
+ return Self . closeConnection ( connection, isShutdown: isShutdown, migrationAction: migrationAction)
535
517
case . scheduleTimeoutTimerAndCreateConnection(
536
518
timeoutID: let connectionID,
537
519
newConnectionID: _,
@@ -548,4 +530,25 @@ extension HTTPConnectionPool.StateMachine.ConnectionAction {
548
530
)
549
531
}
550
532
}
533
+
534
+ private static func closeConnection(
535
+ _ connection: HTTPConnectionPool . Connection ,
536
+ isShutdown: HTTPConnectionPool . StateMachine . ConnectionAction . IsShutdown ,
537
+ migrationAction: HTTPConnectionPool . StateMachine . ConnectionMigrationAction
538
+ ) -> Self {
539
+ guard isShutdown == . no else {
540
+ precondition (
541
+ migrationAction. closeConnections. isEmpty && migrationAction. createConnections. isEmpty,
542
+ " migration actions are not supported during shutdown "
543
+ )
544
+ return . closeConnection( connection, isShutdown: isShutdown)
545
+ }
546
+ var closeConnections = migrationAction. closeConnections
547
+ closeConnections. append ( connection)
548
+ return . migration(
549
+ createConnections: migrationAction. createConnections,
550
+ closeConnections: closeConnections,
551
+ scheduleTimeout: nil
552
+ )
553
+ }
551
554
}
0 commit comments