Skip to content

Commit 5aa2d13

Browse files
committed
Move QueuePool*ForRelease
1 parent c43f371 commit 5aa2d13

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -483,44 +483,6 @@ protected void PruneConnectionPoolGroups(object state)
483483
}
484484
}
485485

486-
internal void QueuePoolForRelease(IDbConnectionPool pool, bool clearing)
487-
{
488-
// Queue the pool up for release -- we'll clear it out and dispose
489-
// of it as the last part of the pruning timer callback so we don't
490-
// do it with the pool entry or the pool collection locked.
491-
Debug.Assert(pool != null, "null pool?");
492-
493-
// set the pool to the shutdown state to force all active
494-
// connections to be automatically disposed when they
495-
// are returned to the pool
496-
pool.Shutdown();
497-
498-
lock (_poolsToRelease)
499-
{
500-
if (clearing)
501-
{
502-
pool.Clear();
503-
}
504-
_poolsToRelease.Add(pool);
505-
}
506-
SqlClientEventSource.Metrics.EnterInactiveConnectionPool();
507-
SqlClientEventSource.Metrics.ExitActiveConnectionPool();
508-
}
509-
510-
internal void QueuePoolGroupForRelease(DbConnectionPoolGroup poolGroup)
511-
{
512-
Debug.Assert(poolGroup != null, "null poolGroup?");
513-
SqlClientEventSource.Log.TryTraceEvent("<prov.DbConnectionFactory.QueuePoolGroupForRelease|RES|INFO|CPOOL> {0}, poolGroup={1}", ObjectID, poolGroup.ObjectID);
514-
515-
lock (_poolGroupsToRelease)
516-
{
517-
_poolGroupsToRelease.Add(poolGroup);
518-
}
519-
520-
SqlClientEventSource.Metrics.EnterInactiveConnectionPoolGroup();
521-
SqlClientEventSource.Metrics.ExitActiveConnectionPoolGroup();
522-
}
523-
524486
abstract protected DbConnectionOptions CreateConnectionOptions(string connectionString, DbConnectionOptions previous);
525487

526488
abstract protected DbConnectionPoolGroupOptions CreateConnectionPoolGroupOptions(DbConnectionOptions options);

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,44 @@ internal SqlInternalConnectionTds CreatePooledConnection(
159159
SqlClientEventSource.Log.TryTraceEvent("<prov.SqlConnectionFactory.CreatePooledConnection|RES|CPOOL> {0}, Pooled database connection created.", ObjectId);
160160
return newConnection;
161161
}
162+
163+
internal void QueuePoolForRelease(IDbConnectionPool pool, bool clearing)
164+
{
165+
// Queue the pool up for release -- we'll clear it out and dispose of it as the last
166+
// part of the pruning timer callback so we don't do it with the pool entry or the pool
167+
// collection locked.
168+
Debug.Assert(pool != null, "null pool?");
169+
170+
// Set the pool to the shutdown state to force all active connections to be
171+
// automatically disposed when they are returned to the pool
172+
pool.Shutdown();
173+
174+
lock (_poolsToRelease)
175+
{
176+
if (clearing)
177+
{
178+
pool.Clear();
179+
}
180+
_poolsToRelease.Add(pool);
181+
}
182+
183+
SqlClientEventSource.Metrics.EnterInactiveConnectionPool();
184+
SqlClientEventSource.Metrics.ExitActiveConnectionPool();
185+
}
186+
187+
internal void QueuePoolGroupForRelease(DbConnectionPoolGroup poolGroup)
188+
{
189+
Debug.Assert(poolGroup != null, "null poolGroup?");
190+
SqlClientEventSource.Log.TryTraceEvent("<prov.SqlConnectionFactory.QueuePoolGroupForRelease|RES|INFO|CPOOL> {0}, poolGroup={1}", ObjectId, poolGroup.ObjectID);
191+
192+
lock (_poolGroupsToRelease)
193+
{
194+
_poolGroupsToRelease.Add(poolGroup);
195+
}
196+
197+
SqlClientEventSource.Metrics.EnterInactiveConnectionPoolGroup();
198+
SqlClientEventSource.Metrics.ExitActiveConnectionPoolGroup();
199+
}
162200

163201
#endregion
164202

0 commit comments

Comments
 (0)