--- C:/MySQL Client/6.9.6 Patched/Source/MySql.Data/MySqlPool.cs Tue May 05 14:37:41 2015 +++ C:/MySQL Client/6.9.6/Source/MySql.Data/MySqlPool.cs Tue Feb 17 20:45:39 2015 @@ -35,7 +35,7 @@ internal sealed class MySqlPool { private List inUsePool; - private List idlePool; + private Queue idlePool; private MySqlConnectionStringBuilder settings; private uint minSize; private uint maxSize; @@ -47,7 +47,7 @@ private void EnqueueIdle(Driver driver) { driver.IdleSince = DateTime.Now; - idlePool.Add(driver); + idlePool.Enqueue(driver); } public MySqlPool(MySqlConnectionStringBuilder settings) { @@ -61,7 +61,7 @@ minSize = maxSize; this.settings = settings; inUsePool = new List((int)maxSize); - idlePool = new List((int)maxSize); + idlePool = new Queue((int)maxSize); // prepopulate the idle pool to minSize for (int i = 0; i < minSize; i++) @@ -120,11 +120,8 @@ // one, then create it here. lock ((idlePool as ICollection).SyncRoot) { - if (HasIdleConnections) - { - driver = idlePool[idlePool.Count-1]; - idlePool.RemoveAt(idlePool.Count-1); - } + if (HasIdleConnections) + driver = idlePool.Dequeue(); } // Obey the connection timeout @@ -279,11 +276,11 @@ beingCleared = true; // then we remove all connections sitting in the idle pool - for (int i = 0; i < idlePool.Count; i++) - { - idlePool[i].Close(); - } - idlePool.Clear(); + while (idlePool.Count > 0) + { + Driver d = idlePool.Dequeue(); + d.Close(); + } // there is nothing left to do here. Now we just wait for all // in use connections to be returned to the pool. When they are @@ -310,18 +307,18 @@ lock ((idlePool as ICollection).SyncRoot) { - // The drivers appear to be ordered reversed by their age, i.e it is + // The drivers appear to be ordered by their age, i.e it is // sufficient to remove them until the first element is not // too old. while (idlePool.Count > minSize) { - Driver d = idlePool[0]; + Driver d = idlePool.Peek(); DateTime expirationTime = d.IdleSince.Add( new TimeSpan(0, 0, MySqlPoolManager.maxConnectionIdleTime)); if (expirationTime.CompareTo(now) < 0) { oldDrivers.Add(d); - idlePool.RemoveAt(0); + idlePool.Dequeue(); } else {