Skip to content

Commit 91c17ad

Browse files
committed
Differentiate pooled connections by their OpenFlags
1 parent ca1c06b commit 91c17ad

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/SQLite.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,7 +2091,7 @@ public enum NotifyTableChangedAction
20912091
/// </summary>
20922092
public class SQLiteConnectionString
20932093
{
2094-
public string ConnectionString { get; }
2094+
public string UniqueKey { get; }
20952095
public string DatabasePath { get; }
20962096
public bool StoreDateTimeAsTicks { get; }
20972097
public object Key { get; }
@@ -2200,7 +2200,7 @@ public SQLiteConnectionString (string databasePath, SQLiteOpenFlags openFlags, b
22002200
if (key != null && !((key is byte[]) || (key is string)))
22012201
throw new ArgumentException ("Encryption keys must be strings or byte arrays", nameof (key));
22022202

2203-
ConnectionString = databasePath;
2203+
UniqueKey = string.Format ("{0}_{1:X8}", databasePath, (uint)openFlags);
22042204
StoreDateTimeAsTicks = storeDateTimeAsTicks;
22052205
Key = key;
22062206
PreKeyAction = preKeyAction;

src/SQLiteAsync.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,9 +1363,9 @@ public static SQLiteConnectionPool Shared {
13631363

13641364
public SQLiteConnectionWithLock GetConnection (SQLiteConnectionString connectionString)
13651365
{
1366+
var key = connectionString.UniqueKey;
13661367
Entry entry;
13671368
lock (_entriesLock) {
1368-
string key = connectionString.ConnectionString;
13691369
if (!_entries.TryGetValue (key, out entry)) {
13701370
entry = new Entry (connectionString);
13711371
_entries[key] = entry;
@@ -1376,15 +1376,13 @@ public SQLiteConnectionWithLock GetConnection (SQLiteConnectionString connection
13761376

13771377
public void CloseConnection (SQLiteConnectionString connectionString)
13781378
{
1379-
var key = connectionString.ConnectionString;
1380-
1379+
var key = connectionString.UniqueKey;
13811380
Entry entry;
13821381
lock (_entriesLock) {
13831382
if (_entries.TryGetValue (key, out entry)) {
13841383
_entries.Remove (key);
13851384
}
13861385
}
1387-
13881386
entry?.Close ();
13891387
}
13901388

@@ -1407,7 +1405,8 @@ public void Reset ()
14071405

14081406
/// <summary>
14091407
/// This is a normal connection except it contains a Lock method that
1410-
/// can be used to serialize access to the database.
1408+
/// can be used to serialize access to the database
1409+
/// in lieu of using the sqlite's FullMutex support.
14111410
/// </summary>
14121411
public class SQLiteConnectionWithLock : SQLiteConnection
14131412
{

0 commit comments

Comments
 (0)