Skip to content

Commit e4fa22e

Browse files
committed
Weakly capture the HTTPConnectionPool in the idle connection timeout task
Currently, the `HTTPConnectionPool` will be kept alive until the idle connection timeout has fired. I don’t see a reason to keep the `HTTPConnectionPool` around if the idle connection timeout future is the only thing that’s still referencing the `HTTPConnectionPool`.
1 parent abb11d5 commit e4fa22e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/AsyncHTTPClient/ConnectionPool/HTTPConnectionPool.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,10 @@ final class HTTPConnectionPool:
394394
"ahc-connection-id": "\(connectionID)"
395395
]
396396
)
397-
let scheduled = eventLoop.scheduleTask(in: self.idleConnectionTimeout) {
397+
let scheduled = eventLoop.scheduleTask(in: self.idleConnectionTimeout) { [weak self] in
398+
guard let self else {
399+
return
400+
}
398401
// there might be a race between a cancelTimer call and the triggering
399402
// of this scheduled task. both want to acquire the lock
400403
self.modifyStateAndRunActions { stateMachine in

0 commit comments

Comments
 (0)