File tree Expand file tree Collapse file tree 2 files changed +4
-16
lines changed
src/MongoDB.Driver.Core/Core/ConnectionPools Expand file tree Collapse file tree 2 files changed +4
-16
lines changed Original file line number Diff line number Diff line change @@ -745,7 +745,7 @@ public void Clear()
745
745
}
746
746
}
747
747
748
- public void Prune ( )
748
+ public void Prune ( CancellationToken cancellationToken )
749
749
{
750
750
PooledConnection [ ] expiredConnections ;
751
751
lock ( _lock )
@@ -755,6 +755,8 @@ public void Prune()
755
755
756
756
foreach ( var connection in expiredConnections )
757
757
{
758
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
759
+
758
760
lock ( _lock )
759
761
{
760
762
// At this point connection is always expired and might be disposed
Original file line number Diff line number Diff line change @@ -299,7 +299,7 @@ private async Task MaintainSizeAsync(CancellationToken cancellationToken)
299
299
{
300
300
try
301
301
{
302
- await PrunePoolAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
302
+ _connectionHolder . Prune ( cancellationToken ) ;
303
303
await EnsureMinSizeAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
304
304
}
305
305
catch
@@ -315,20 +315,6 @@ private async Task MaintainSizeAsync(CancellationToken cancellationToken)
315
315
}
316
316
}
317
317
318
- private async Task PrunePoolAsync ( CancellationToken cancellationToken )
319
- {
320
- using ( var poolAwaiter = _maxConnectionsQueue . CreateAwaiter ( ) )
321
- {
322
- var entered = await poolAwaiter . WaitSignaledAsync ( TimeSpan . FromMilliseconds ( 20 ) , cancellationToken ) . ConfigureAwait ( false ) ;
323
- if ( ! entered )
324
- {
325
- return ;
326
- }
327
-
328
- _connectionHolder . Prune ( ) ;
329
- }
330
- }
331
-
332
318
private async Task EnsureMinSizeAsync ( CancellationToken cancellationToken )
333
319
{
334
320
var minTimeout = TimeSpan . FromMilliseconds ( 20 ) ;
You can’t perform that action at this time.
0 commit comments