update locking

This commit is contained in:
Luke Pulverenti 2016-01-31 19:57:40 -05:00
parent 7ac682f06c
commit 0297d8f7d3
5 changed files with 14 additions and 10 deletions

View File

@ -233,7 +233,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
/// <summary> /// <summary>
/// The _triggers /// The _triggers
/// </summary> /// </summary>
private IEnumerable<ITaskTrigger> _triggers; private volatile List<ITaskTrigger> _triggers;
/// <summary> /// <summary>
/// The _triggers sync lock /// The _triggers sync lock
/// </summary> /// </summary>
@ -532,7 +532,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
/// Loads the triggers. /// Loads the triggers.
/// </summary> /// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns> /// <returns>IEnumerable{BaseTaskTrigger}.</returns>
private IEnumerable<ITaskTrigger> LoadTriggers() private List<ITaskTrigger> LoadTriggers()
{ {
try try
{ {
@ -543,12 +543,12 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
catch (FileNotFoundException) catch (FileNotFoundException)
{ {
// File doesn't exist. No biggie. Return defaults. // File doesn't exist. No biggie. Return defaults.
return ScheduledTask.GetDefaultTriggers(); return ScheduledTask.GetDefaultTriggers().ToList();
} }
catch (DirectoryNotFoundException) catch (DirectoryNotFoundException)
{ {
// File doesn't exist. No biggie. Return defaults. // File doesn't exist. No biggie. Return defaults.
return ScheduledTask.GetDefaultTriggers(); return ScheduledTask.GetDefaultTriggers().ToList();
} }
} }

View File

@ -109,7 +109,7 @@ namespace MediaBrowser.Controller.Entities
/// <value>The last activity date.</value> /// <value>The last activity date.</value>
public DateTime? LastActivityDate { get; set; } public DateTime? LastActivityDate { get; set; }
private UserConfiguration _config; private volatile UserConfiguration _config;
private readonly object _configSyncLock = new object(); private readonly object _configSyncLock = new object();
[IgnoreDataMember] [IgnoreDataMember]
public UserConfiguration Configuration public UserConfiguration Configuration
@ -132,7 +132,7 @@ namespace MediaBrowser.Controller.Entities
set { _config = value; } set { _config = value; }
} }
private UserPolicy _policy; private volatile UserPolicy _policy;
private readonly object _policySyncLock = new object(); private readonly object _policySyncLock = new object();
[IgnoreDataMember] [IgnoreDataMember]
public UserPolicy Policy public UserPolicy Policy

View File

@ -222,7 +222,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// <summary> /// <summary>
/// The _root folder /// The _root folder
/// </summary> /// </summary>
private AggregateFolder _rootFolder; private volatile AggregateFolder _rootFolder;
/// <summary> /// <summary>
/// The _root folder sync lock /// The _root folder sync lock
/// </summary> /// </summary>
@ -743,7 +743,7 @@ namespace MediaBrowser.Server.Implementations.Library
return rootFolder; return rootFolder;
} }
private UserRootFolder _userRootFolder; private volatile UserRootFolder _userRootFolder;
private readonly object _syncLock = new object(); private readonly object _syncLock = new object();
public Folder GetUserRootFolder() public Folder GetUserRootFolder()
{ {

View File

@ -239,7 +239,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
public Task CancelSeriesTimerAsync(string timerId, CancellationToken cancellationToken) public Task CancelSeriesTimerAsync(string timerId, CancellationToken cancellationToken)
{ {
var timers = _timerProvider.GetAll().Where(i => string.Equals(i.SeriesTimerId, timerId, StringComparison.OrdinalIgnoreCase)); var timers = _timerProvider
.GetAll()
.Where(i => string.Equals(i.SeriesTimerId, timerId, StringComparison.OrdinalIgnoreCase))
.ToList();
foreach (var timer in timers) foreach (var timer in timers)
{ {
CancelTimerInternal(timer.Id); CancelTimerInternal(timer.Id);

View File

@ -13,7 +13,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
where T : class where T : class
{ {
private readonly object _fileDataLock = new object(); private readonly object _fileDataLock = new object();
private List<T> _items; private volatile List<T> _items;
private readonly IJsonSerializer _jsonSerializer; private readonly IJsonSerializer _jsonSerializer;
protected readonly ILogger Logger; protected readonly ILogger Logger;
private readonly string _dataPath; private readonly string _dataPath;