diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-12-11 00:12:00 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-12-11 00:12:00 -0500 |
| commit | a9a808a9c407a14af9e041cff20e7fe6af3e5061 (patch) | |
| tree | d4ebcc94333e1b7604f3b88d4daf749cfa822dc9 /Emby.Server.Implementations/Notifications/SqliteNotificationsRepository.cs | |
| parent | 0c2489059d80fd5d56fc0c894cfe6e784fc685fa (diff) | |
fix db locking errors
Diffstat (limited to 'Emby.Server.Implementations/Notifications/SqliteNotificationsRepository.cs')
| -rw-r--r-- | Emby.Server.Implementations/Notifications/SqliteNotificationsRepository.cs | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/Emby.Server.Implementations/Notifications/SqliteNotificationsRepository.cs b/Emby.Server.Implementations/Notifications/SqliteNotificationsRepository.cs index aae41da19..43e19da65 100644 --- a/Emby.Server.Implementations/Notifications/SqliteNotificationsRepository.cs +++ b/Emby.Server.Implementations/Notifications/SqliteNotificationsRepository.cs @@ -51,24 +51,24 @@ namespace Emby.Server.Implementations.Notifications { var result = new NotificationResult(); - using (var connection = CreateConnection(true)) - { - using (WriteLock.Read()) - { - var clauses = new List<string>(); - var paramList = new List<object>(); + var clauses = new List<string>(); + var paramList = new List<object>(); - if (query.IsRead.HasValue) - { - clauses.Add("IsRead=?"); - paramList.Add(query.IsRead.Value); - } + if (query.IsRead.HasValue) + { + clauses.Add("IsRead=?"); + paramList.Add(query.IsRead.Value); + } - clauses.Add("UserId=?"); - paramList.Add(query.UserId.ToGuidParamValue()); + clauses.Add("UserId=?"); + paramList.Add(query.UserId.ToGuidParamValue()); - var whereClause = " where " + string.Join(" And ", clauses.ToArray()); + var whereClause = " where " + string.Join(" And ", clauses.ToArray()); + using (var connection = CreateConnection(true)) + { + lock (WriteLock) + { result.TotalRecordCount = connection.Query("select count(Id) from Notifications" + whereClause, paramList.ToArray()).SelectScalarInt().First(); var commandText = string.Format("select Id,UserId,Date,Name,Description,Url,Level,IsRead,Category,RelatedId from Notifications{0} order by IsRead asc, Date desc", whereClause); @@ -108,7 +108,7 @@ namespace Emby.Server.Implementations.Notifications using (var connection = CreateConnection(true)) { - using (WriteLock.Read()) + lock (WriteLock) { using (var statement = connection.PrepareStatement("select Level from Notifications where UserId=@UserId and IsRead=@IsRead")) { @@ -225,7 +225,7 @@ namespace Emby.Server.Implementations.Notifications using (var connection = CreateConnection()) { - using (WriteLock.Write()) + lock (WriteLock) { connection.RunInTransaction(conn => { @@ -288,7 +288,7 @@ namespace Emby.Server.Implementations.Notifications using (var connection = CreateConnection()) { - using (WriteLock.Write()) + lock (WriteLock) { connection.RunInTransaction(conn => { @@ -310,7 +310,7 @@ namespace Emby.Server.Implementations.Notifications using (var connection = CreateConnection()) { - using (WriteLock.Write()) + lock (WriteLock) { connection.RunInTransaction(conn => { |
