diff --git a/src/SQLite.cs b/src/SQLite.cs index 76c1fe5f..0ce075e0 100644 --- a/src/SQLite.cs +++ b/src/SQLite.cs @@ -2091,7 +2091,7 @@ public enum NotifyTableChangedAction /// public class SQLiteConnectionString { - public string ConnectionString { get; } + public string UniqueKey { get; } public string DatabasePath { get; } public bool StoreDateTimeAsTicks { get; } public object Key { get; } @@ -2200,7 +2200,7 @@ public SQLiteConnectionString (string databasePath, SQLiteOpenFlags openFlags, b if (key != null && !((key is byte[]) || (key is string))) throw new ArgumentException ("Encryption keys must be strings or byte arrays", nameof (key)); - ConnectionString = databasePath; + UniqueKey = string.Format ("{0}_{1:X8}", databasePath, (uint)openFlags); StoreDateTimeAsTicks = storeDateTimeAsTicks; Key = key; PreKeyAction = preKeyAction; diff --git a/src/SQLiteAsync.cs b/src/SQLiteAsync.cs index 15a63b97..77255098 100644 --- a/src/SQLiteAsync.cs +++ b/src/SQLiteAsync.cs @@ -1363,9 +1363,9 @@ public static SQLiteConnectionPool Shared { public SQLiteConnectionWithLock GetConnection (SQLiteConnectionString connectionString) { + var key = connectionString.UniqueKey; Entry entry; lock (_entriesLock) { - string key = connectionString.ConnectionString; if (!_entries.TryGetValue (key, out entry)) { entry = new Entry (connectionString); _entries[key] = entry; @@ -1376,15 +1376,13 @@ public SQLiteConnectionWithLock GetConnection (SQLiteConnectionString connection public void CloseConnection (SQLiteConnectionString connectionString) { - var key = connectionString.ConnectionString; - + var key = connectionString.UniqueKey; Entry entry; lock (_entriesLock) { if (_entries.TryGetValue (key, out entry)) { _entries.Remove (key); } } - entry?.Close (); } @@ -1407,7 +1405,8 @@ public void Reset () /// /// This is a normal connection except it contains a Lock method that - /// can be used to serialize access to the database. + /// can be used to serialize access to the database + /// in lieu of using the sqlite's FullMutex support. /// public class SQLiteConnectionWithLock : SQLiteConnection {