Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
48 lines (42 loc) · 1.51 KB

File metadata and controls

48 lines (42 loc) · 1.51 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Concurrent;
namespace Npgsql;
/// <summary>
/// Provides lookup for a pool based on a connection string.
/// </summary>
/// <remarks>
/// Note that pools created directly as <see cref="NpgsqlDataSource" /> are referenced directly by users, and aren't managed here.
/// </remarks>
static class PoolManager
{
internal static ConcurrentDictionary<string, NpgsqlDataSource> Pools { get; } = new();
internal static void Clear(string connString)
{
// TODO: Actually remove the pools from here, #3387 (but be careful of concurrency)
if (Pools.TryGetValue(connString, out var pool))
pool.Clear();
}
internal static void ClearAll()
{
// TODO: Actually remove the pools from here, #3387 (but be careful of concurrency)
foreach (var pool in Pools.Values)
pool.Clear();
}
static PoolManager()
{
// When the appdomain gets unloaded (e.g. web app redeployment) attempt to nicely
// close idle connectors to prevent errors in PostgreSQL logs (#491).
AppDomain.CurrentDomain.DomainUnload += (_, _) => ClearAll();
AppDomain.CurrentDomain.ProcessExit += (_, _) => ClearAll();
}
/// <summary>
/// Resets the pool manager to its initial state, for test purposes only.
/// Assumes that no other threads are accessing the pool.
/// </summary>
internal static void Reset()
{
// TODO: Remove once #3387 is implemented
ClearAll();
Pools.Clear();
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.