Skip to content

Commit 56a89bb

Browse files
committed
FbConnectionPoolManager cleanup on process exit or domain unload (DNET-802).
1 parent 6a61dc2 commit 56a89bb

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Provider/src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbConnectionPoolManager.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,13 @@
2020
using System.Collections.Generic;
2121
using System.Linq;
2222
using System.Threading;
23-
using System.Threading.Tasks;
2423
using FirebirdSql.Data.Common;
2524

2625
namespace FirebirdSql.Data.FirebirdClient
2726
{
2827
sealed class FbConnectionPoolManager : IDisposable
2928
{
30-
static Lazy<FbConnectionPoolManager> _instanceLazy = new Lazy<FbConnectionPoolManager>(() => new FbConnectionPoolManager(), LazyThreadSafetyMode.ExecutionAndPublication);
31-
32-
internal static FbConnectionPoolManager Instance
33-
{
34-
get { return _instanceLazy.Value; }
35-
}
29+
internal static FbConnectionPoolManager Instance { get; private set; }
3630

3731
sealed class Pool : IDisposable
3832
{
@@ -187,6 +181,15 @@ FbConnectionInternal CreateNewConnectionIfPossibleImpl(FbConnectionString connec
187181
ConcurrentDictionary<string, Pool> _pools;
188182
Timer _cleanupTimer;
189183

184+
static FbConnectionPoolManager()
185+
{
186+
Instance = new FbConnectionPoolManager();
187+
#if !NETSTANDARD1_6
188+
AppDomain.CurrentDomain.DomainUnload += (sender, args) => Instance.Dispose();
189+
AppDomain.CurrentDomain.ProcessExit += (sender, args) => Instance.Dispose();
190+
#endif
191+
}
192+
190193
FbConnectionPoolManager()
191194
{
192195
_disposed = 0;

0 commit comments

Comments
 (0)