Skip to content

Commit 4852538

Browse files
benaadamsstephentoub
authored andcommitted
Don't capture AsyncLocals into ODBC Global Timers (dotnet#26066)
1 parent ec353e2 commit 4852538

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/System.Data.Odbc/src/Common/System/Data/ProviderBase/DbConnectionFactory.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,11 @@ internal virtual DbConnectionPoolGroupProviderInfo CreateConnectionPoolGroupProv
121121
}
122122

123123
private Timer CreatePruningTimer()
124-
{
125-
TimerCallback callback = new TimerCallback(PruneConnectionPoolGroups);
126-
return new Timer(callback, null, PruningDueTime, PruningPeriod);
127-
}
124+
=> ADP.UnsafeCreateTimer(
125+
new TimerCallback(PruneConnectionPoolGroups),
126+
null,
127+
PruningDueTime,
128+
PruningPeriod);
128129

129130
protected DbConnectionOptions FindConnectionOptions(DbConnectionPoolKey key)
130131
{

src/System.Data.Odbc/src/Common/System/Data/ProviderBase/DbConnectionPool.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,11 @@ internal void Clear()
382382
}
383383

384384
private Timer CreateCleanupTimer()
385-
{
386-
return (new Timer(new TimerCallback(this.CleanupCallback), null, _cleanupWait, _cleanupWait));
387-
}
385+
=> ADP.UnsafeCreateTimer(
386+
new TimerCallback(CleanupCallback),
387+
null,
388+
_cleanupWait,
389+
_cleanupWait);
388390

389391
private DbConnectionInternal CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
390392
{

src/System.Data.Odbc/src/System.Data.Odbc.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
<Compile Include="$(CommonPath)\System\Data\Common\AdapterUtil.cs">
3333
<Link>Common\System\Data\Common\AdapterUtil.cs</Link>
3434
</Compile>
35+
<Compile Include="$(CommonPath)\System\Data\Common\AdapterUtil.Drivers.cs">
36+
<Link>System\Data\Common\AdapterUtil.Drivers.cs</Link>
37+
</Compile>
3538
<Compile Include="Common\System\Data\Common\AdapterUtil.Odbc.cs" />
3639
<Compile Include="Common\System\Data\Common\DbConnectionOptions.cs" />
3740
<Compile Include="$(CommonPath)\System\Data\Common\DbConnectionOptions.Common.cs">

0 commit comments

Comments
 (0)