From 82495f9ac31da23c7c1ea3b425e5effb45b51bb9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 26 Jan 2016 13:18:21 -0500 Subject: [PATCH] rework device concurrency --- .../Devices/DeviceRepository.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs b/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs index 43b1e693cc..9e4a45253d 100644 --- a/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs +++ b/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs @@ -25,7 +25,7 @@ namespace MediaBrowser.Server.Implementations.Devices private readonly ILogger _logger; private readonly IFileSystem _fileSystem; - private ConcurrentBag _devices; + private List _devices; public DeviceRepository(IApplicationPaths appPaths, IJsonSerializer json, ILogger logger, IFileSystem fileSystem) { @@ -93,17 +93,14 @@ namespace MediaBrowser.Server.Implementations.Devices public IEnumerable GetDevices() { - if (_devices == null) + lock (_syncLock) { - lock (_syncLock) + if (_devices == null) { - if (_devices == null) - { - _devices = new ConcurrentBag(LoadDevices()); - } + _devices = LoadDevices().ToList(); } + return _devices.ToList(); } - return _devices.ToList(); } private IEnumerable LoadDevices()