Skip to content

Commit 1a51229

Browse files
committed
Tolerate multiple calls to shutdown()
1 parent 3b3b5d0 commit 1a51229

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Sources/AsyncHTTPClient/ConnectionPool/HTTP2/HTTP2Connection.swift

+5-4
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ final class HTTP2Connection {
267267
self.channel.eventLoop.assertInEventLoop()
268268

269269
switch self.state {
270-
case .active, .starting:
270+
case .active:
271271
self.state = .closing
272272

273273
// inform all open streams, that the currently running request should be cancelled.
@@ -279,10 +279,11 @@ final class HTTP2Connection {
279279
// are closed.
280280
self.channel.triggerUserOutboundEvent(HTTPConnectionEvent.shutdownRequested, promise: nil)
281281

282-
case .closed:
283-
// we are already closed and we need to tolerate this
282+
case .closed, .closing:
283+
// we are already closing/closed and we need to tolerate this
284284
break
285-
case .initialized, .closing:
285+
286+
case .initialized, .starting:
286287
preconditionFailure("invalid state \(self.state)")
287288
}
288289
}

0 commit comments

Comments
 (0)