diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
index bd3fa7597d..14ac8aab60 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
@@ -53,9 +53,6 @@
Microsoft\Data\Common\DbConnectionOptions.Common.cs
-
- Microsoft\Data\Common\DbConnectionPoolKey.cs
-
Microsoft\Data\Common\DbConnectionStringCommon.cs
@@ -71,38 +68,56 @@
Microsoft\Data\OperationAbortedException.cs
+
+ Microsoft\Data\ProviderBase\DbConnectionInternal.cs
+
Microsoft\Data\ProviderBase\DbConnectionClosed.cs
Microsoft\Data\ProviderBase\DbConnectionFactory.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPool.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPool.cs
-
- Microsoft\Data\ProviderBase\DbConnectionInternal.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolAuthenticationContext.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolAuthenticationContextKey.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolAuthenticationContext.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolGroup.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolAuthenticationContextKey.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolGroupProviderInfo.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolGroup.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolIdentity.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolGroupProviderInfo.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolKey.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolIdentity.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolOptions.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolOptions.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolProviderInfo.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolProviderInfo.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolState.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\WaitHandleDbConnectionPool.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\SqlConnectionPoolGroupProviderInfo.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\SqlConnectionPoolKey.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\SqlConnectionPoolProviderInfo.cs
Microsoft\Data\ProviderBase\DbMetaDataFactory.cs
@@ -419,15 +434,6 @@
Microsoft\Data\SqlClient\SqlConnectionEncryptOptionConverter.cs
-
- Microsoft\Data\SqlClient\SqlConnectionPoolGroupProviderInfo.cs
-
-
- Microsoft\Data\SqlClient\SqlConnectionPoolKey.cs
-
-
- Microsoft\Data\SqlClient\SqlConnectionPoolProviderInfo.cs
-
Microsoft\Data\SqlClient\SqlConnectionString.cs
@@ -783,8 +789,8 @@
Microsoft\Data\Common\AdapterUtil.Windows.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolIdentity.Windows.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolIdentity.Windows.cs
Microsoft\Data\Sql\SqlDataSourceEnumeratorNativeHelper.cs
@@ -827,8 +833,8 @@
Microsoft\Data\Common\AdapterUtil.Unix.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolIdentity.Unix.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolIdentity.Unix.cs
Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Unix.cs
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs
index 863996629e..059f18c596 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs
@@ -19,6 +19,7 @@
using System.Threading.Tasks;
using Microsoft.Data.Common;
using Microsoft.Data.ProviderBase;
+using Microsoft.Data.SqlClient.ConnectionPool;
using Microsoft.Data.SqlClient.Diagnostics;
using Microsoft.SqlServer.Server;
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs
index dfa10c3b07..ca9bcc2cd9 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs
@@ -8,6 +8,7 @@
using System.IO;
using Microsoft.Data.Common;
using Microsoft.Data.ProviderBase;
+using Microsoft.Data.SqlClient.ConnectionPool;
namespace Microsoft.Data.SqlClient
{
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs
index aa8420d8bb..c8e782c0b3 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs
@@ -10,6 +10,7 @@
using System.Transactions;
using Microsoft.Data.Common;
using Microsoft.Data.ProviderBase;
+using Microsoft.Data.SqlClient.ConnectionPool;
namespace Microsoft.Data.SqlClient
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
index 9b65f20d6f..d128268185 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
@@ -17,6 +17,7 @@
using System.Transactions;
using Microsoft.Data.Common;
using Microsoft.Data.ProviderBase;
+using Microsoft.Data.SqlClient.ConnectionPool;
using Microsoft.Identity.Client;
namespace Microsoft.Data.SqlClient
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
index d74f887ea9..9fa5f41c8e 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
@@ -241,9 +241,6 @@
Microsoft\Data\Common\DbConnectionOptions.Common.cs
-
- Microsoft\Data\Common\DbConnectionPoolKey.cs
-
Microsoft\Data\Common\MultipartIdentifier.cs
@@ -265,35 +262,53 @@
Microsoft\Data\ProviderBase\DbConnectionInternal.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPool.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPool.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolAuthenticationContext.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolAuthenticationContextKey.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolCounters.netfx.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolGroup.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolGroupProviderInfo.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolAuthenticationContext.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolIdentity.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolAuthenticationContextKey.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolIdentity.Windows.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolCounters.netfx.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolKey.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolGroup.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolOptions.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolGroupProviderInfo.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolProviderInfo.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolIdentity.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolState.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolIdentity.Windows.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\WaitHandleDbConnectionPool.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolOptions.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\SqlConnectionPoolGroupProviderInfo.cs
-
- Microsoft\Data\ProviderBase\DbConnectionPoolProviderInfo.cs
+
+ Microsoft\Data\SqlClient\SqlConnectionPoolKey.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\SqlConnectionPoolProviderInfo.cs
Microsoft\Data\ProviderBase\DbMetaDataFactory.cs
@@ -658,15 +673,6 @@
Microsoft\Data\SqlClient\SqlConnectionEncryptOptionConverter.cs
-
- Microsoft\Data\SqlClient\SqlConnectionPoolGroupProviderInfo.cs
-
-
- Microsoft\Data\SqlClient\SqlConnectionPoolKey.cs
-
-
- Microsoft\Data\SqlClient\SqlConnectionPoolProviderInfo.cs
-
Microsoft\Data\SqlClient\SqlConnectionString.cs
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs
index 09a4ae7a90..7f5817b6fe 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs
@@ -25,6 +25,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Data.ProviderBase;
+using Microsoft.Data.SqlClient.ConnectionPool;
using Microsoft.SqlServer.Server;
[assembly: InternalsVisibleTo("System.Data.DataSetExtensions, PublicKey=" + Microsoft.Data.SqlClient.AssemblyRef.EcmaPublicKeyFull)] // DevDiv Bugs 92166
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs
index 755e2dd747..d9bf71b663 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs
@@ -11,6 +11,7 @@
using System.Runtime.Versioning;
using Microsoft.Data.Common;
using Microsoft.Data.ProviderBase;
+using Microsoft.Data.SqlClient.ConnectionPool;
using Microsoft.Data.SqlClient.Server;
namespace Microsoft.Data.SqlClient
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs
index 54d31d5301..9f8ddb7930 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs
@@ -10,9 +10,10 @@ namespace Microsoft.Data.SqlClient
using System.Diagnostics;
using System.Runtime.ConstrainedExecution;
using System.Threading;
+ using System.Transactions;
using Microsoft.Data.Common;
using Microsoft.Data.ProviderBase;
- using System.Transactions;
+ using Microsoft.Data.SqlClient.ConnectionPool;
public sealed partial class SqlConnection : DbConnection
{
@@ -79,7 +80,7 @@ internal DbConnectionOptions ConnectionOptions
{
get
{
- Microsoft.Data.ProviderBase.DbConnectionPoolGroup poolGroup = PoolGroup;
+ DbConnectionPoolGroup poolGroup = PoolGroup;
return poolGroup != null ? poolGroup.ConnectionOptions : null;
}
}
@@ -102,7 +103,7 @@ private void ConnectionString_Set(string value)
private void ConnectionString_Set(DbConnectionPoolKey key)
{
DbConnectionOptions connectionOptions = null;
- Microsoft.Data.ProviderBase.DbConnectionPoolGroup poolGroup = ConnectionFactory.GetConnectionPoolGroup(key, null, ref connectionOptions);
+ DbConnectionPoolGroup poolGroup = ConnectionFactory.GetConnectionPoolGroup(key, null, ref connectionOptions);
DbConnectionInternal connectionInternal = InnerConnection;
bool flag = connectionInternal.AllowSetConnectionString;
if (flag)
@@ -144,7 +145,7 @@ internal DbConnectionInternal InnerConnection
}
}
- internal Microsoft.Data.ProviderBase.DbConnectionPoolGroup PoolGroup
+ internal DbConnectionPoolGroup PoolGroup
{
get
{
@@ -341,7 +342,7 @@ internal void PermissionDemand()
{
Debug.Assert(DbConnectionClosedConnecting.SingletonInstance == _innerConnection, "not connecting");
- Microsoft.Data.ProviderBase.DbConnectionPoolGroup poolGroup = PoolGroup;
+ DbConnectionPoolGroup poolGroup = PoolGroup;
DbConnectionOptions connectionOptions = poolGroup != null ? poolGroup.ConnectionOptions : null;
if (connectionOptions == null || connectionOptions.IsEmpty)
{
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
index 2e9c61d8c8..1d4b224522 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
@@ -17,6 +17,7 @@
using System.Threading.Tasks;
using Microsoft.Data.Common;
using Microsoft.Data.ProviderBase;
+using Microsoft.Data.SqlClient.ConnectionPool;
using Microsoft.Identity.Client;
using System.Transactions;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs
index b25f9a2d3b..b8ada9b1bc 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs
@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using Microsoft.Data.Common;
+using Microsoft.Data.SqlClient.ConnectionPool;
using System.Data;
using System.Data.Common;
using System.Diagnostics;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs
index 0fdd85c4bf..f357e6109b 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs
@@ -11,6 +11,7 @@
using System.Threading.Tasks;
using Microsoft.Data.Common;
using Microsoft.Data.SqlClient;
+using Microsoft.Data.SqlClient.ConnectionPool;
namespace Microsoft.Data.ProviderBase
{
@@ -577,7 +578,7 @@ private void PruneConnectionPoolGroups(object state)
if (0 == pool.Count)
{
_poolsToRelease.Remove(pool);
- SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, ReleasePool={1}", ObjectID, pool.ObjectID);
+ SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, ReleasePool={1}", ObjectID, pool.ObjectId);
#if NETFRAMEWORK
PerformanceCounters.NumberOfInactiveConnectionPools.Decrement();
#else
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs
index 9744b8db9b..7268f00eea 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs
@@ -11,6 +11,7 @@
using System.Transactions;
using Microsoft.Data.Common;
using Microsoft.Data.SqlClient;
+using Microsoft.Data.SqlClient.ConnectionPool;
#if NETFRAMEWORK
using System.Runtime.ConstrainedExecution;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPool.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPool.cs
new file mode 100644
index 0000000000..a4efd25d2c
--- /dev/null
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPool.cs
@@ -0,0 +1,72 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Collections.Concurrent;
+using System.Data.Common;
+using System.Threading.Tasks;
+using System.Transactions;
+using Microsoft.Data.Common;
+using Microsoft.Data.ProviderBase;
+
+namespace Microsoft.Data.SqlClient.ConnectionPool
+{
+ internal abstract class DbConnectionPool
+ {
+ private static int _objectTypeCount;
+
+ internal int ObjectId { get; } = System.Threading.Interlocked.Increment(ref _objectTypeCount);
+
+ internal DbConnectionPoolState State { get; set; }
+
+ #region Abstract Properties
+ internal abstract int Count { get; }
+
+ internal abstract DbConnectionFactory ConnectionFactory { get; }
+
+ internal abstract bool ErrorOccurred { get; }
+
+ internal abstract TimeSpan LoadBalanceTimeout { get; }
+
+ internal abstract DbConnectionPoolIdentity Identity { get; }
+
+ internal abstract bool IsRunning { get; }
+
+#if NETFRAMEWORK
+ internal abstract DbConnectionPoolCounters PerformanceCounters { get; }
+#endif
+ internal abstract DbConnectionPoolGroup PoolGroup { get; }
+
+ internal abstract DbConnectionPoolGroupOptions PoolGroupOptions { get; }
+
+ internal abstract DbConnectionPoolProviderInfo ProviderInfo { get; }
+
+ internal abstract ConcurrentDictionary AuthenticationContexts { get; }
+
+ internal abstract bool UseLoadBalancing { get; }
+ #endregion
+
+ #region Abstract Methods
+ internal abstract void Clear();
+
+ internal abstract void DestroyObject(DbConnectionInternal obj);
+
+ internal abstract bool TryGetConnection(DbConnection owningObject, TaskCompletionSource retry, DbConnectionOptions userOptions, out DbConnectionInternal connection);
+
+ internal abstract DbConnectionInternal ReplaceConnection(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection);
+
+ internal abstract void PutNewObject(DbConnectionInternal obj);
+
+ internal abstract void PutObject(DbConnectionInternal obj, object owningObject);
+
+ internal abstract void PutObjectFromTransactedPool(DbConnectionInternal obj);
+
+ internal abstract void Startup();
+
+ internal abstract void Shutdown();
+
+ internal abstract void TransactionEnded(Transaction transaction, DbConnectionInternal transactedObject);
+ #endregion
+ }
+}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolAuthenticationContext.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolAuthenticationContext.cs
similarity index 98%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolAuthenticationContext.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolAuthenticationContext.cs
index 29ac7fee31..71dbc3c714 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolAuthenticationContext.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolAuthenticationContext.cs
@@ -7,7 +7,7 @@
using System.Runtime.ConstrainedExecution;
using System.Threading;
-namespace Microsoft.Data.ProviderBase
+namespace Microsoft.Data.SqlClient.ConnectionPool
{
///
/// Represents the context of an authentication attempt when using the new active directory based authentication mechanisms.
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolAuthenticationContextKey.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolAuthenticationContextKey.cs
similarity index 98%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolAuthenticationContextKey.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolAuthenticationContextKey.cs
index a6f15ca999..e12648b3d0 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolAuthenticationContextKey.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolAuthenticationContextKey.cs
@@ -5,7 +5,7 @@
using System;
using System.Diagnostics;
-namespace Microsoft.Data.ProviderBase
+namespace Microsoft.Data.SqlClient.ConnectionPool
{
///
/// Represents the key of dbConnectionPoolAuthenticationContext.
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolCounters.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolCounters.netfx.cs
similarity index 99%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolCounters.netfx.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolCounters.netfx.cs
index 04b9e37a61..0eadb7f42c 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolCounters.netfx.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolCounters.netfx.cs
@@ -6,7 +6,7 @@
#if NETFRAMEWORK
-namespace Microsoft.Data.ProviderBase
+namespace Microsoft.Data.SqlClient.ConnectionPool
{
using System;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroup.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolGroup.cs
similarity index 98%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroup.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolGroup.cs
index 687ee095f3..5aaa4fdcd7 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroup.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolGroup.cs
@@ -4,13 +4,13 @@
using Microsoft.Data.Common;
-using Microsoft.Data.SqlClient;
+using Microsoft.Data.ProviderBase;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
-namespace Microsoft.Data.ProviderBase
+namespace Microsoft.Data.SqlClient.ConnectionPool
{
// set_ConnectionString calls DbConnectionFactory.GetConnectionPoolGroup
// when not found a new pool entry is created and potentially added
@@ -187,7 +187,7 @@ internal DbConnectionPool GetConnectionPool(DbConnectionFactory connectionFactor
if (!_poolCollection.TryGetValue(currentIdentity, out pool))
{
DbConnectionPoolProviderInfo connectionPoolProviderInfo = connectionFactory.CreateConnectionPoolProviderInfo(ConnectionOptions);
- DbConnectionPool newPool = new(connectionFactory, this, currentIdentity, connectionPoolProviderInfo);
+ DbConnectionPool newPool = new WaitHandleDbConnectionPool(connectionFactory, this, currentIdentity, connectionPoolProviderInfo);
if (MarkPoolGroupAsActive())
{
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroupProviderInfo.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolGroupProviderInfo.cs
similarity index 91%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroupProviderInfo.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolGroupProviderInfo.cs
index 3eceb6d3e3..9ee83357bd 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroupProviderInfo.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolGroupProviderInfo.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace Microsoft.Data.ProviderBase
+namespace Microsoft.Data.SqlClient.ConnectionPool
{
internal class DbConnectionPoolGroupProviderInfo
{
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolIdentity.Unix.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.Unix.cs
similarity index 88%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolIdentity.Unix.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.Unix.cs
index 95769c3e6c..3eadc8761a 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolIdentity.Unix.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.Unix.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace Microsoft.Data.ProviderBase
+namespace Microsoft.Data.SqlClient.ConnectionPool
{
partial class DbConnectionPoolIdentity
{
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolIdentity.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.Windows.cs
similarity index 97%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolIdentity.Windows.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.Windows.cs
index 62fbc34aed..175d4c8595 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolIdentity.Windows.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.Windows.cs
@@ -8,7 +8,7 @@
using System.Security.Principal;
using Microsoft.Data.SqlClient;
-namespace Microsoft.Data.ProviderBase
+namespace Microsoft.Data.SqlClient.ConnectionPool
{
partial class DbConnectionPoolIdentity
{
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolIdentity.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.cs
similarity index 98%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolIdentity.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.cs
index e97f55a7ad..5716146a6b 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolIdentity.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace Microsoft.Data.ProviderBase
+namespace Microsoft.Data.SqlClient.ConnectionPool
{
sealed internal partial class DbConnectionPoolIdentity
{
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/DbConnectionPoolKey.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolKey.cs
similarity index 96%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/DbConnectionPoolKey.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolKey.cs
index 7d2799289f..bfcd4cd2ef 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/DbConnectionPoolKey.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolKey.cs
@@ -4,7 +4,7 @@
using System;
-namespace Microsoft.Data.Common
+namespace Microsoft.Data.SqlClient.ConnectionPool
{
// DbConnectionPoolKey: Base class implementation of a key to connection pool groups
// Only connection string is used as a key
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolOptions.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolOptions.cs
similarity index 97%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolOptions.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolOptions.cs
index 866453432c..7adf8abdc2 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolOptions.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolOptions.cs
@@ -4,7 +4,7 @@
using System;
-namespace Microsoft.Data.ProviderBase
+namespace Microsoft.Data.SqlClient.ConnectionPool
{
internal sealed class DbConnectionPoolGroupOptions
{
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolProviderInfo.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolProviderInfo.cs
similarity index 84%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolProviderInfo.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolProviderInfo.cs
index 5392795dff..1afeb473be 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolProviderInfo.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolProviderInfo.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace Microsoft.Data.ProviderBase
+namespace Microsoft.Data.SqlClient.ConnectionPool
{
internal class DbConnectionPoolProviderInfo
{
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolState.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolState.cs
new file mode 100644
index 0000000000..1790e38a57
--- /dev/null
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolState.cs
@@ -0,0 +1,13 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace Microsoft.Data.SqlClient.ConnectionPool
+{
+ internal enum DbConnectionPoolState
+ {
+ Initializing,
+ Running,
+ ShuttingDown,
+ }
+}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionPoolGroupProviderInfo.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/SqlConnectionPoolGroupProviderInfo.cs
similarity index 98%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionPoolGroupProviderInfo.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/SqlConnectionPoolGroupProviderInfo.cs
index 47de649bbd..1fe1768c0a 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionPoolGroupProviderInfo.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/SqlConnectionPoolGroupProviderInfo.cs
@@ -3,9 +3,8 @@
// See the LICENSE file in the project root for more information.
using System.Security;
-using Microsoft.Data.ProviderBase;
-namespace Microsoft.Data.SqlClient
+namespace Microsoft.Data.SqlClient.ConnectionPool
{
internal sealed class SqlConnectionPoolGroupProviderInfo : DbConnectionPoolGroupProviderInfo
{
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionPoolKey.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/SqlConnectionPoolKey.cs
similarity index 98%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionPoolKey.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/SqlConnectionPoolKey.cs
index 04a0d32281..207c0a8e1a 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionPoolKey.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/SqlConnectionPoolKey.cs
@@ -8,7 +8,7 @@
using System.Threading.Tasks;
using Microsoft.Data.Common;
-namespace Microsoft.Data.SqlClient
+namespace Microsoft.Data.SqlClient.ConnectionPool
{
// SqlConnectionPoolKey: Implementation of a key to connection pool groups for specifically to be used for SqlConnection
// Connection string and SqlCredential are used as a key
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionPoolProviderInfo.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/SqlConnectionPoolProviderInfo.cs
similarity index 89%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionPoolProviderInfo.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/SqlConnectionPoolProviderInfo.cs
index eee7550f5e..9c6df4d245 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionPoolProviderInfo.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/SqlConnectionPoolProviderInfo.cs
@@ -2,9 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using Microsoft.Data.ProviderBase;
-namespace Microsoft.Data.SqlClient
+namespace Microsoft.Data.SqlClient.ConnectionPool
{
internal sealed class SqlConnectionPoolProviderInfo : DbConnectionPoolProviderInfo
{
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/WaitHandleDbConnectionPool.cs
similarity index 91%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/WaitHandleDbConnectionPool.cs
index 53554f503d..8dd1a7d745 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/WaitHandleDbConnectionPool.cs
@@ -9,26 +9,18 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
-using System.Runtime.ConstrainedExecution;
-using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
using System.Transactions;
using Microsoft.Data.Common;
-using Microsoft.Data.SqlClient;
+using Microsoft.Data.ProviderBase;
+using static Microsoft.Data.SqlClient.ConnectionPool.DbConnectionPoolState;
-namespace Microsoft.Data.ProviderBase
+namespace Microsoft.Data.SqlClient.ConnectionPool
{
- internal sealed class DbConnectionPool
+ internal sealed class WaitHandleDbConnectionPool : DbConnectionPool
{
- private enum State
- {
- Initializing,
- Running,
- ShuttingDown,
- }
-
// This class is a way to stash our cloned Tx key for later disposal when it's no longer needed.
// We can't get at the key in the dictionary without enumerating entries, so we stash an extra
// copy as part of the value.
@@ -79,7 +71,7 @@ internal TransactedConnectionPool(DbConnectionPool pool)
_pool = pool;
_transactedCxns = new Dictionary();
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Constructed for connection pool {1}", ObjectID, _pool.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Constructed for connection pool {1}", ObjectID, _pool.ObjectId);
}
internal int ObjectID
@@ -362,17 +354,17 @@ internal WaitHandle[] GetHandles(bool withCreate)
}
}
- private const int MAX_Q_SIZE = (int)0x00100000;
+ private const int MAX_Q_SIZE = 0x00100000;
// The order of these is important; we want the WaitAny call to be signaled
// for a free object before a creation signal. Only the index first signaled
// object is returned from the WaitAny call.
- private const int SEMAPHORE_HANDLE = (int)0x0;
- private const int ERROR_HANDLE = (int)0x1;
- private const int CREATION_HANDLE = (int)0x2;
- private const int BOGUS_HANDLE = (int)0x3;
+ private const int SEMAPHORE_HANDLE = 0x0;
+ private const int ERROR_HANDLE = 0x1;
+ private const int CREATION_HANDLE = 0x2;
+ private const int BOGUS_HANDLE = 0x3;
- private const int WAIT_ABANDONED = (int)0x80;
+ private const int WAIT_ABANDONED = 0x80;
private const int ERROR_WAIT_DEFAULT = 5 * 1000; // 5 seconds
@@ -392,8 +384,6 @@ internal WaitHandle[] GetHandles(bool withCreate)
///
private readonly ConcurrentDictionary _pooledDbAuthenticationContexts;
- private State _state;
-
private readonly ConcurrentStack _stackOld = new ConcurrentStack();
private readonly ConcurrentStack _stackNew = new ConcurrentStack();
@@ -418,11 +408,8 @@ internal WaitHandle[] GetHandles(bool withCreate)
private readonly List _objectList;
private int _totalObjects;
- private static int _objectTypeCount; // EventSource counter
- internal readonly int _objectID = System.Threading.Interlocked.Increment(ref _objectTypeCount);
-
// only created by DbConnectionPoolGroup.GetConnectionPool
- internal DbConnectionPool(
+ internal WaitHandleDbConnectionPool(
DbConnectionFactory connectionFactory,
DbConnectionPoolGroup connectionPoolGroup,
DbConnectionPoolIdentity identity,
@@ -435,7 +422,7 @@ internal DbConnectionPool(
throw ADP.InternalError(ADP.InternalErrorCode.AttemptingToPoolOnRestrictedToken);
}
- _state = State.Initializing;
+ State = Initializing;
lock (s_random)
{
@@ -462,8 +449,8 @@ internal DbConnectionPool(
_transactedConnectionPool = new TransactedConnectionPool(this);
_poolCreateRequest = new WaitCallback(PoolCreateRequest); // used by CleanupCallback
- _state = State.Running;
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Constructed.", ObjectID);
+ State = Running;
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Constructed.", ObjectId);
//_cleanupTimer & QueuePoolCreateRequest is delayed until DbConnectionPoolGroup calls
// StartBackgroundCallbacks after pool is actually in the collection
@@ -474,36 +461,21 @@ private int CreationTimeout
get { return PoolGroupOptions.CreationTimeout; }
}
- internal int Count
- {
- get { return _totalObjects; }
- }
+ internal override int Count => _totalObjects;
- internal DbConnectionFactory ConnectionFactory
- {
- get { return _connectionFactory; }
- }
+ internal override DbConnectionFactory ConnectionFactory => _connectionFactory;
- internal bool ErrorOccurred
- {
- get { return _errorOccurred; }
- }
+ internal override bool ErrorOccurred => _errorOccurred;
- private bool HasTransactionAffinity
- {
- get { return PoolGroupOptions.HasTransactionAffinity; }
- }
+ private bool HasTransactionAffinity => PoolGroupOptions.HasTransactionAffinity;
- internal TimeSpan LoadBalanceTimeout
- {
- get { return PoolGroupOptions.LoadBalanceTimeout; }
- }
+ internal override TimeSpan LoadBalanceTimeout => PoolGroupOptions.LoadBalanceTimeout;
private bool NeedToReplenish
{
get
{
- if (State.Running != _state) // Don't allow connection create when not running.
+ if (State is not Running) // Don't allow connection create when not running.
return false;
int totalObjects = Count;
@@ -514,7 +486,7 @@ private bool NeedToReplenish
if (totalObjects < MinPoolSize)
return true;
- int freeObjects = (_stackNew.Count + _stackOld.Count);
+ int freeObjects = _stackNew.Count + _stackOld.Count;
int waitingRequests = _waitCount;
bool needToReplenish = (freeObjects < waitingRequests) || ((freeObjects == waitingRequests) && (totalObjects > 1));
@@ -522,76 +494,35 @@ private bool NeedToReplenish
}
}
- internal DbConnectionPoolIdentity Identity
- {
- get { return _identity; }
- }
+ internal override DbConnectionPoolIdentity Identity => _identity;
- internal bool IsRunning
+ internal override bool IsRunning
{
- get { return State.Running == _state; }
+ get { return State is Running; }
}
- private int MaxPoolSize
- {
- get { return PoolGroupOptions.MaxPoolSize; }
- }
+ private int MaxPoolSize => PoolGroupOptions.MaxPoolSize;
- private int MinPoolSize
- {
- get { return PoolGroupOptions.MinPoolSize; }
- }
-
- internal int ObjectID
- {
- get
- {
- return _objectID;
- }
- }
+ private int MinPoolSize => PoolGroupOptions.MinPoolSize;
#if NETFRAMEWORK
- internal DbConnectionPoolCounters PerformanceCounters
- {
- get { return _connectionFactory.PerformanceCounters; }
- }
+ internal override DbConnectionPoolCounters PerformanceCounters => _connectionFactory.PerformanceCounters;
#endif
- internal DbConnectionPoolGroup PoolGroup
- {
- get { return _connectionPoolGroup; }
- }
+ internal override DbConnectionPoolGroup PoolGroup => _connectionPoolGroup;
- internal DbConnectionPoolGroupOptions PoolGroupOptions
- {
- get { return _connectionPoolGroupOptions; }
- }
+ internal override DbConnectionPoolGroupOptions PoolGroupOptions => _connectionPoolGroupOptions;
- internal DbConnectionPoolProviderInfo ProviderInfo
- {
- get { return _connectionPoolProviderInfo; }
- }
+ internal override DbConnectionPoolProviderInfo ProviderInfo => _connectionPoolProviderInfo;
///
/// Return the pooled authentication contexts.
///
- internal ConcurrentDictionary AuthenticationContexts
- {
- get
- {
- return _pooledDbAuthenticationContexts;
- }
- }
+ internal override ConcurrentDictionary AuthenticationContexts => _pooledDbAuthenticationContexts;
- internal bool UseLoadBalancing
- {
- get { return PoolGroupOptions.UseLoadBalancing; }
- }
+ internal override bool UseLoadBalancing => PoolGroupOptions.UseLoadBalancing;
- private bool UsingIntegrateSecurity
- {
- get { return _identity != null && DbConnectionPoolIdentity.NoIdentity != _identity; }
- }
+ private bool UsingIntegrateSecurity => _identity != null && DbConnectionPoolIdentity.NoIdentity != _identity;
private void CleanupCallback(object state)
{
@@ -613,11 +544,11 @@ private void CleanupCallback(object state)
//
// With this logic, objects are pruned from the pool if unused for
// at least one period but not more than two periods.
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}", ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}", ObjectId);
// Destroy free objects that put us above MinPoolSize from old stack.
while (Count > MinPoolSize)
- {
+ {
// While above MinPoolSize...
if (_waitHandles.PoolSemaphore.WaitOne(0, false))
{
@@ -691,7 +622,7 @@ private void CleanupCallback(object state)
break;
Debug.Assert(obj != null, "null connection is not expected");
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, ChangeStacks={1}", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, ChangeStacks={1}", ObjectId, obj.ObjectID);
Debug.Assert(!obj.IsEmancipated, "pooled object not in pool");
Debug.Assert(obj.CanBePooled, "pooled object is not poolable");
@@ -704,9 +635,9 @@ private void CleanupCallback(object state)
QueuePoolCreateRequest();
}
- internal void Clear()
+ internal override void Clear()
{
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Clearing.", ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Clearing.", ObjectId);
DbConnectionInternal obj;
// First, quickly doom everything.
@@ -750,7 +681,7 @@ internal void Clear()
// Finally, reclaim everything that's emancipated (which, because
// it's been doomed, will cause it to be disposed of as well)
ReclaimEmancipatedObjects();
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Cleared.", ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Cleared.", ObjectId);
}
private Timer CreateCleanupTimer() =>
@@ -825,21 +756,7 @@ private DbConnectionInternal CreateObject(DbConnection owningObject, DbConnectio
#endif
}
- // If the old connection belonged to another pool, we need to remove it from that
- if (oldConnection != null)
- {
- var oldConnectionPool = oldConnection.Pool;
- if (oldConnectionPool != null && oldConnectionPool != this)
- {
- Debug.Assert(oldConnectionPool._state == State.ShuttingDown, "Old connections pool should be shutting down");
- lock (oldConnectionPool._objectList)
- {
- oldConnectionPool._objectList.Remove(oldConnection);
- oldConnectionPool._totalObjects = oldConnectionPool._objectList.Count;
- }
- }
- }
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Added to pool.", ObjectID, newObj?.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Added to pool.", ObjectId, newObj?.ObjectID);
// Reset the error wait:
_errorWait = ERROR_WAIT_DEFAULT;
@@ -910,7 +827,7 @@ private DbConnectionInternal CreateObject(DbConnection owningObject, DbConnectio
private void DeactivateObject(DbConnectionInternal obj)
{
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Deactivating.", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Deactivating.", ObjectId, obj.ObjectID);
obj.DeactivateConnection();
bool returnToGeneralPool = false;
@@ -926,7 +843,7 @@ private void DeactivateObject(DbConnectionInternal obj)
{
// NOTE: constructor should ensure that current state cannot be State.Initializing, so it can only
// be State.Running or State.ShuttingDown
- Debug.Assert(_state == State.Running || _state == State.ShuttingDown);
+ Debug.Assert(State is Running or ShuttingDown);
lock (obj)
{
@@ -936,7 +853,7 @@ private void DeactivateObject(DbConnectionInternal obj)
// transaction object will ensure that it is owned (not lost),
// and it will be certain to put it back into the pool.
- if (_state == State.ShuttingDown)
+ if (State is ShuttingDown)
{
if (obj.IsTransactionRoot)
{
@@ -1039,7 +956,7 @@ private void DeactivateObject(DbConnectionInternal obj)
Debug.Assert(rootTxn == true || returnToGeneralPool == true || destroyObject == true);
}
- internal void DestroyObject(DbConnectionInternal obj)
+ internal override void DestroyObject(DbConnectionInternal obj)
{
// A connection with a delegated transaction cannot be disposed of
// until the delegated transaction has actually completed. Instead,
@@ -1048,11 +965,11 @@ internal void DestroyObject(DbConnectionInternal obj)
// again.
if (obj.IsTxRootWaitingForTxEnd)
{
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Has Delegated Transaction, waiting to Dispose.", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Has Delegated Transaction, waiting to Dispose.", ObjectId, obj.ObjectID);
}
else
{
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Removing from pool.", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Removing from pool.", ObjectId, obj.ObjectID);
bool removed = false;
lock (_objectList)
{
@@ -1063,7 +980,7 @@ internal void DestroyObject(DbConnectionInternal obj)
if (removed)
{
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Removed from pool.", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Removed from pool.", ObjectId, obj.ObjectID);
#if NET
SqlClientEventSource.Log.ExitPooledConnection();
#else
@@ -1071,7 +988,7 @@ internal void DestroyObject(DbConnectionInternal obj)
#endif
}
obj.Dispose();
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Disposed.", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Disposed.", ObjectId, obj.ObjectID);
#if NET
SqlClientEventSource.Log.HardDisconnectRequest();
#else
@@ -1082,7 +999,7 @@ internal void DestroyObject(DbConnectionInternal obj)
private void ErrorCallback(object state)
{
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Resetting Error handling.", ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Resetting Error handling.", ObjectId);
_errorOccurred = false;
_waitHandles.ErrorEvent.Reset();
@@ -1219,7 +1136,7 @@ private void WaitForPendingOpen()
} while (_pendingOpens.TryPeek(out next));
}
- internal bool TryGetConnection(DbConnection owningObject, TaskCompletionSource retry, DbConnectionOptions userOptions, out DbConnectionInternal connection)
+ internal override bool TryGetConnection(DbConnection owningObject, TaskCompletionSource retry, DbConnectionOptions userOptions, out DbConnectionInternal connection)
{
uint waitForMultipleObjectsTimeout = 0;
bool allowCreate = false;
@@ -1235,9 +1152,9 @@ internal bool TryGetConnection(DbConnection owningObject, TaskCompletionSource {0}, DbConnectionInternal State != Running.", ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, DbConnectionInternal State != Running.", ObjectId);
connection = null;
return true;
}
@@ -1285,7 +1202,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
#if NETFRAMEWORK
PerformanceCounters.SoftConnectsPerSecond.Increment();
#endif
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Getting connection.", ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Getting connection.", ObjectId);
// If automatic transaction enlistment is required, then we try to
// get the connection from the transacted connection pool first.
@@ -1328,19 +1245,19 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
switch (waitResult)
{
case WaitHandle.WaitTimeout:
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Wait timed out.", ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Wait timed out.", ObjectId);
Interlocked.Decrement(ref _waitCount);
connection = null;
return false;
case ERROR_HANDLE:
// Throw the error that PoolCreateRequest stashed.
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Errors are set.", ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Errors are set.", ObjectId);
Interlocked.Decrement(ref _waitCount);
throw TryCloneCachedException();
case CREATION_HANDLE:
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Creating new connection.", ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Creating new connection.", ObjectId);
try
{
obj = UserCreateRequest(owningObject, userOptions);
@@ -1393,7 +1310,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
if ((obj != null) && (!obj.IsConnectionAlive()))
{
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, found dead and removed.", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, found dead and removed.", ObjectId, obj.ObjectID);
DestroyObject(obj);
obj = null; // Setting to null in case creating a new object fails
@@ -1406,7 +1323,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
#endif
try
{
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Creating new connection.", ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Creating new connection.", ObjectId);
obj = UserCreateRequest(owningObject, userOptions);
}
finally
@@ -1417,7 +1334,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
else
{
// Timeout waiting for creation semaphore - return null
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Wait timed out.", ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Wait timed out.", ObjectId);
connection = null;
return false;
}
@@ -1425,23 +1342,23 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
}
break;
- case (WAIT_ABANDONED + SEMAPHORE_HANDLE):
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Semaphore handle abandonded.", ObjectID);
+ case WAIT_ABANDONED + SEMAPHORE_HANDLE:
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Semaphore handle abandonded.", ObjectId);
Interlocked.Decrement(ref _waitCount);
throw new AbandonedMutexException(SEMAPHORE_HANDLE, _waitHandles.PoolSemaphore);
- case (WAIT_ABANDONED + ERROR_HANDLE):
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Error handle abandonded.", ObjectID);
+ case WAIT_ABANDONED + ERROR_HANDLE:
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Error handle abandonded.", ObjectId);
Interlocked.Decrement(ref _waitCount);
throw new AbandonedMutexException(ERROR_HANDLE, _waitHandles.ErrorEvent);
- case (WAIT_ABANDONED + CREATION_HANDLE):
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Creation handle abandoned.", ObjectID);
+ case WAIT_ABANDONED + CREATION_HANDLE:
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Creation handle abandoned.", ObjectId);
Interlocked.Decrement(ref _waitCount);
throw new AbandonedMutexException(CREATION_HANDLE, _waitHandles.CreationSemaphore);
default:
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, WaitForMultipleObjects={1}", ObjectID, waitResult);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, WaitForMultipleObjects={1}", ObjectId, waitResult);
Interlocked.Decrement(ref _waitCount);
throw ADP.InternalError(ADP.InternalErrorCode.UnexpectedWaitAnyResult);
}
@@ -1501,12 +1418,12 @@ private void PrepareConnection(DbConnection owningObject, DbConnectionInternal o
/// Options used to create the new connection
/// Inner connection that will be replaced
/// A new inner connection that is attached to the
- internal DbConnectionInternal ReplaceConnection(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
+ internal override DbConnectionInternal ReplaceConnection(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
{
#if NETFRAMEWORK
PerformanceCounters.SoftConnectsPerSecond.Increment();
#endif
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, replacing connection.", ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, replacing connection.", ObjectId);
DbConnectionInternal newConnection = UserCreateRequest(owningObject, userOptions, oldConnection);
if (newConnection != null)
@@ -1550,14 +1467,14 @@ private DbConnectionInternal GetFromGeneralPool()
if (obj != null)
{
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Popped from general pool.", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Popped from general pool.", ObjectId, obj.ObjectID);
#if NET
SqlClientEventSource.Log.ExitFreeConnection();
#else
PerformanceCounters.NumberOfFreeConnections.Decrement();
#endif
}
- return (obj);
+ return obj;
}
private DbConnectionInternal GetFromTransactedPool(out Transaction transaction)
@@ -1571,7 +1488,7 @@ private DbConnectionInternal GetFromTransactedPool(out Transaction transaction)
if (obj != null)
{
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Popped from transacted pool.", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Popped from transacted pool.", ObjectId, obj.ObjectID);
#if NET
SqlClientEventSource.Log.ExitFreeConnection();
#else
@@ -1586,14 +1503,14 @@ private DbConnectionInternal GetFromTransactedPool(out Transaction transaction)
}
catch
{
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, found dead and removed.", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, found dead and removed.", ObjectId, obj.ObjectID);
DestroyObject(obj);
throw;
}
}
else if (!obj.IsConnectionAlive())
{
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, found dead and removed.", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, found dead and removed.", ObjectId, obj.ObjectID);
DestroyObject(obj);
obj = null;
}
@@ -1610,10 +1527,10 @@ private void PoolCreateRequest(object state)
{
// called by pooler to ensure pool requests are currently being satisfied -
// creation mutex has not been obtained
- long scopeID = SqlClientEventSource.Log.TryPoolerScopeEnterEvent(" {0}", ObjectID);
+ long scopeID = SqlClientEventSource.Log.TryPoolerScopeEnterEvent(" {0}", ObjectId);
try
{
- if (State.Running == _state)
+ if (State is Running)
{
// in case WaitForPendingOpen ever failed with no subsequent OpenAsync calls,
// start it back up again
@@ -1704,7 +1621,7 @@ private void PoolCreateRequest(object state)
else
{
// trace waitResult and ignore the failure
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, PoolCreateRequest called WaitForSingleObject failed {1}", ObjectID, waitResult);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, PoolCreateRequest called WaitForSingleObject failed {1}", ObjectId, waitResult);
}
}
catch (Exception e)
@@ -1717,7 +1634,7 @@ private void PoolCreateRequest(object state)
// Now that CreateObject can throw, we need to catch the exception and discard it.
// There is no further action we can take beyond tracing. The error will be
// thrown to the user the next time they request a connection.
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, PoolCreateRequest called CreateConnection which threw an exception: {1}", ObjectID, e);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, PoolCreateRequest called CreateConnection which threw an exception: {1}", ObjectId, e);
}
finally
{
@@ -1737,11 +1654,11 @@ private void PoolCreateRequest(object state)
}
}
- internal void PutNewObject(DbConnectionInternal obj)
+ internal override void PutNewObject(DbConnectionInternal obj)
{
Debug.Assert(obj != null, "why are we adding a null object to the pool?");
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Pushing to general pool.", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Pushing to general pool.", ObjectId, obj.ObjectID);
_stackNew.Push(obj);
_waitHandles.PoolSemaphore.Release(1);
@@ -1753,7 +1670,7 @@ internal void PutNewObject(DbConnectionInternal obj)
}
- internal void PutObject(DbConnectionInternal obj, object owningObject)
+ internal override void PutObject(DbConnectionInternal obj, object owningObject)
{
Debug.Assert(obj != null, "null obj?");
@@ -1785,7 +1702,7 @@ internal void PutObject(DbConnectionInternal obj, object owningObject)
DeactivateObject(obj);
}
- internal void PutObjectFromTransactedPool(DbConnectionInternal obj)
+ internal override void PutObjectFromTransactedPool(DbConnectionInternal obj)
{
Debug.Assert(obj != null, "null pooledObject?");
Debug.Assert(obj.EnlistedTransaction == null, "pooledObject is still enlisted?");
@@ -1800,9 +1717,9 @@ internal void PutObjectFromTransactedPool(DbConnectionInternal obj)
// method, we can safely presume that the caller is the only person
// that is using the connection, and that all pre-push logic has been
// done and all transactions are ended.
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Transaction has ended.", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Transaction has ended.", ObjectId, obj.ObjectID);
- if (_state == State.Running && obj.CanBePooled)
+ if (State is Running && obj.CanBePooled)
{
PutNewObject(obj);
}
@@ -1815,7 +1732,7 @@ internal void PutObjectFromTransactedPool(DbConnectionInternal obj)
private void QueuePoolCreateRequest()
{
- if (State.Running == _state)
+ if (State is Running)
{
// Make sure we're at quota by posting a callback to the threadpool.
ThreadPool.QueueUserWorkItem(_poolCreateRequest);
@@ -1825,7 +1742,7 @@ private void QueuePoolCreateRequest()
private bool ReclaimEmancipatedObjects()
{
bool emancipatedObjectFound = false;
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}", ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}", ObjectId);
List reclaimedObjects = new List();
int count;
@@ -1877,7 +1794,7 @@ private bool ReclaimEmancipatedObjects()
for (int i = 0; i < count; ++i)
{
DbConnectionInternal obj = reclaimedObjects[i];
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Reclaiming.", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Connection {1}, Reclaiming.", ObjectId, obj.ObjectID);
#if NET
SqlClientEventSource.Log.ReclaimedConnectionRequest();
#else
@@ -1892,9 +1809,9 @@ private bool ReclaimEmancipatedObjects()
return emancipatedObjectFound;
}
- internal void Startup()
+ internal override void Startup()
{
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, CleanupWait={1}", ObjectID, _cleanupWait);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, CleanupWait={1}", ObjectId, _cleanupWait);
_cleanupTimer = CreateCleanupTimer();
if (NeedToReplenish)
@@ -1903,10 +1820,10 @@ internal void Startup()
}
}
- internal void Shutdown()
+ internal override void Shutdown()
{
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}", ObjectID);
- _state = State.ShuttingDown;
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}", ObjectId);
+ State = ShuttingDown;
// deactivate timer callbacks
Timer t = _cleanupTimer;
@@ -1921,13 +1838,13 @@ internal void Shutdown()
// that is implemented inside DbConnectionPool. This method's counterpart (PutTransactedObject) should
// only be called from DbConnectionPool.DeactivateObject and thus the plumbing to provide access to
// other objects is unnecessary (hence the asymmetry of Ended but no Begin)
- internal void TransactionEnded(Transaction transaction, DbConnectionInternal transactedObject)
+ internal override void TransactionEnded(Transaction transaction, DbConnectionInternal transactedObject)
{
Debug.Assert(transaction != null, "null transaction?");
Debug.Assert(transactedObject != null, "null transactedObject?");
// Note: connection may still be associated with transaction due to Explicit Unbinding requirement.
- SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Transaction Completed", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID);
+ SqlClientEventSource.Log.TryPoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Transaction Completed", ObjectId, transaction.GetHashCode(), transactedObject.ObjectID);
// called by the internal connection when it get's told that the
// transaction is completed. We tell the transacted pool to remove
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependency.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependency.cs
index 44bee53a75..d2fdd6ef0e 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependency.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependency.cs
@@ -11,8 +11,8 @@
using System.Threading;
using System.Xml;
using Microsoft.Data.Common;
-using Microsoft.Data.ProviderBase;
using Microsoft.Data.Sql;
+using Microsoft.Data.SqlClient.ConnectionPool;
#if NETFRAMEWORK
using System.IO;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs
index b7e1fe183e..89d54e3196 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs
@@ -11,8 +11,8 @@
using System.Threading;
using System.Xml;
using Microsoft.Data.Common;
-using Microsoft.Data.ProviderBase;
using Microsoft.Data.SqlClient;
+using Microsoft.Data.SqlClient.ConnectionPool;
#if NETFRAMEWORK
using System.Runtime.CompilerServices;
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Common/SystemDataInternals/ConnectionPoolHelper.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Common/SystemDataInternals/ConnectionPoolHelper.cs
index d7c5471427..e930f437e9 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Common/SystemDataInternals/ConnectionPoolHelper.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Common/SystemDataInternals/ConnectionPoolHelper.cs
@@ -14,23 +14,24 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests.SystemDataInternals
internal static class ConnectionPoolHelper
{
private static Assembly s_MicrosoftDotData = Assembly.Load(new AssemblyName(typeof(SqlConnection).GetTypeInfo().Assembly.FullName));
- private static Type s_dbConnectionPool = s_MicrosoftDotData.GetType("Microsoft.Data.ProviderBase.DbConnectionPool");
- private static Type s_dbConnectionPoolGroup = s_MicrosoftDotData.GetType("Microsoft.Data.ProviderBase.DbConnectionPoolGroup");
- private static Type s_dbConnectionPoolIdentity = s_MicrosoftDotData.GetType("Microsoft.Data.ProviderBase.DbConnectionPoolIdentity");
+ private static Type s_dbConnectionPool = s_MicrosoftDotData.GetType("Microsoft.Data.SqlClient.ConnectionPool.DbConnectionPool");
+ private static Type s_waitHandleDbConnectionPool = s_MicrosoftDotData.GetType("Microsoft.Data.SqlClient.ConnectionPool.WaitHandleDbConnectionPool");
+ private static Type s_dbConnectionPoolGroup = s_MicrosoftDotData.GetType("Microsoft.Data.SqlClient.ConnectionPool.DbConnectionPoolGroup");
+ private static Type s_dbConnectionPoolIdentity = s_MicrosoftDotData.GetType("Microsoft.Data.SqlClient.ConnectionPool.DbConnectionPoolIdentity");
private static Type s_dbConnectionFactory = s_MicrosoftDotData.GetType("Microsoft.Data.ProviderBase.DbConnectionFactory");
private static Type s_sqlConnectionFactory = s_MicrosoftDotData.GetType("Microsoft.Data.SqlClient.SqlConnectionFactory");
- private static Type s_dbConnectionPoolKey = s_MicrosoftDotData.GetType("Microsoft.Data.Common.DbConnectionPoolKey");
+ private static Type s_dbConnectionPoolKey = s_MicrosoftDotData.GetType("Microsoft.Data.SqlClient.ConnectionPool.DbConnectionPoolKey");
private static Type s_dictStringPoolGroup = typeof(Dictionary<,>).MakeGenericType(s_dbConnectionPoolKey, s_dbConnectionPoolGroup);
private static Type s_dictPoolIdentityPool = typeof(ConcurrentDictionary<,>).MakeGenericType(s_dbConnectionPoolIdentity, s_dbConnectionPool);
- private static PropertyInfo s_dbConnectionPoolCount = s_dbConnectionPool.GetProperty("Count", BindingFlags.Instance | BindingFlags.NonPublic);
+ private static PropertyInfo s_dbConnectionPoolCount = s_waitHandleDbConnectionPool.GetProperty("Count", BindingFlags.Instance | BindingFlags.NonPublic);
private static PropertyInfo s_dictStringPoolGroupGetKeys = s_dictStringPoolGroup.GetProperty("Keys");
private static PropertyInfo s_dictPoolIdentityPoolValues = s_dictPoolIdentityPool.GetProperty("Values");
private static FieldInfo s_dbConnectionFactoryPoolGroupList = s_dbConnectionFactory.GetField("_connectionPoolGroups", BindingFlags.Instance | BindingFlags.NonPublic);
private static FieldInfo s_dbConnectionPoolGroupPoolCollection = s_dbConnectionPoolGroup.GetField("_poolCollection", BindingFlags.Instance | BindingFlags.NonPublic);
private static FieldInfo s_sqlConnectionFactorySingleton = s_sqlConnectionFactory.GetField("SingletonInstance", BindingFlags.Static | BindingFlags.Public);
- private static FieldInfo s_dbConnectionPoolStackOld = s_dbConnectionPool.GetField("_stackOld", BindingFlags.Instance | BindingFlags.NonPublic);
- private static FieldInfo s_dbConnectionPoolStackNew = s_dbConnectionPool.GetField("_stackNew", BindingFlags.Instance | BindingFlags.NonPublic);
- private static MethodInfo s_dbConnectionPoolCleanup = s_dbConnectionPool.GetMethod("CleanupCallback", BindingFlags.Instance | BindingFlags.NonPublic);
+ private static FieldInfo s_dbConnectionPoolStackOld = s_waitHandleDbConnectionPool.GetField("_stackOld", BindingFlags.Instance | BindingFlags.NonPublic);
+ private static FieldInfo s_dbConnectionPoolStackNew = s_waitHandleDbConnectionPool.GetField("_stackNew", BindingFlags.Instance | BindingFlags.NonPublic);
+ private static MethodInfo s_dbConnectionPoolCleanup = s_waitHandleDbConnectionPool.GetMethod("CleanupCallback", BindingFlags.Instance | BindingFlags.NonPublic);
private static MethodInfo s_dictStringPoolGroupTryGetValue = s_dictStringPoolGroup.GetMethod("TryGetValue");
public static int CountFreeConnections(object pool)