Skip to content

Commit

Permalink
FbConnectionPoolManager cleanup on process exit or domain unload (DNE…
Browse files Browse the repository at this point in the history
…T-802).
  • Loading branch information
cincuranet committed Jan 22, 2019
1 parent 6a61dc2 commit 56a89bb
Showing 1 changed file with 10 additions and 7 deletions.
Expand Up @@ -20,19 +20,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using FirebirdSql.Data.Common;

namespace FirebirdSql.Data.FirebirdClient
{
sealed class FbConnectionPoolManager : IDisposable
{
static Lazy<FbConnectionPoolManager> _instanceLazy = new Lazy<FbConnectionPoolManager>(() => new FbConnectionPoolManager(), LazyThreadSafetyMode.ExecutionAndPublication);

internal static FbConnectionPoolManager Instance
{
get { return _instanceLazy.Value; }
}
internal static FbConnectionPoolManager Instance { get; private set; }

sealed class Pool : IDisposable
{
Expand Down Expand Up @@ -187,6 +181,15 @@ FbConnectionInternal CreateNewConnectionIfPossibleImpl(FbConnectionString connec
ConcurrentDictionary<string, Pool> _pools;
Timer _cleanupTimer;

static FbConnectionPoolManager()
{
Instance = new FbConnectionPoolManager();
#if !NETSTANDARD1_6
AppDomain.CurrentDomain.DomainUnload += (sender, args) => Instance.Dispose();
AppDomain.CurrentDomain.ProcessExit += (sender, args) => Instance.Dispose();
#endif
}

FbConnectionPoolManager()
{
_disposed = 0;
Expand Down

0 comments on commit 56a89bb

Please sign in to comment.