diff --git a/Sources/GRPC/ConnectionManager.swift b/Sources/GRPC/ConnectionManager.swift index 93cbc7527..af483adb7 100644 --- a/Sources/GRPC/ConnectionManager.swift +++ b/Sources/GRPC/ConnectionManager.swift @@ -1218,6 +1218,11 @@ extension ConnectionManager { internal func startConnecting() { self.manager.startConnecting() } + + /// Shutdown the manager now. + internal func shutdownNow() { + self.manager._shutdown(mode: .forceful, promise: self.manager.eventLoop.makePromise()) + } } } diff --git a/Sources/GRPC/ConnectionPool/ConnectionPool.swift b/Sources/GRPC/ConnectionPool/ConnectionPool.swift index 7ae82b6e6..c8d5dd149 100644 --- a/Sources/GRPC/ConnectionPool/ConnectionPool.swift +++ b/Sources/GRPC/ConnectionPool/ConnectionPool.swift @@ -760,6 +760,7 @@ extension ConnectionPool: ConnectionManagerConnectivityDelegate { assert(hadActiveConnection) if let removed = self._connections.removeValue(forKey: manager.id) { removed.manager.sync.http2Delegate = nil + removed.manager.sync.shutdownNow() // Manager may have internal state to tear down. self.delegate?.connectionClosed(id: .init(removed.manager.id), error: nil) self.delegate?.connectionRemoved(id: .init(removed.manager.id)) }