We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6264afd commit 009576aCopy full SHA for 009576a
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs
@@ -1979,7 +1979,11 @@ public bool CleanCacheAndDisposeIfUnused()
1979
}
1980
1981
// Dispose the stale connections outside the pool lock, to avoid holding the lock too long.
1982
- toDispose?.ForEach(c => c.Dispose());
+ // Dispose them asynchronously to not to block the caller on closing the SslStream or NetworkStream.
1983
+ if (toDispose is not null)
1984
+ {
1985
+ Task.Run(() => toDispose.ForEach(c => c.Dispose()));
1986
+ }
1987
1988
// Pool is active. Should not be removed.
1989
return false;
0 commit comments