Skip to content

Commit f774f2b

Browse files
author
Brian Crowell
committed
Pool: Lock queues when clearing them
We lock queues in all other circumstances, so we need to be consistent.
1 parent 070b2d0 commit f774f2b

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

Npgsql/Npgsql/NpgsqlConnectorPool.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -565,22 +565,25 @@ private static void ClearQueue(ConnectorQueue Queue)
565565
return;
566566
}
567567

568-
while (Queue.Available.Count > 0)
568+
lock (Queue)
569569
{
570-
NpgsqlConnector connector = Queue.Available.Dequeue();
571-
572-
try
573-
{
574-
connector.Close();
575-
}
576-
catch
570+
while (Queue.Available.Count > 0)
577571
{
578-
// Maybe we should log something here to say we got an exception while closing connector?
572+
NpgsqlConnector connector = Queue.Available.Dequeue();
573+
574+
try
575+
{
576+
connector.Close();
577+
}
578+
catch
579+
{
580+
// Maybe we should log something here to say we got an exception while closing connector?
581+
}
579582
}
580-
}
581583

582-
//Clear the busy list so that the current connections don't get re-added to the queue
583-
Queue.Busy.Clear();
584+
//Clear the busy list so that the current connections don't get re-added to the queue
585+
Queue.Busy.Clear();
586+
}
584587
}
585588

586589
internal void ClearPool(NpgsqlConnection Connection)

0 commit comments

Comments
 (0)