aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordkanada <dkanada@users.noreply.github.com>2019-11-02 02:07:20 +0900
committerGitHub <noreply@github.com>2019-11-02 02:07:20 +0900
commit48a99366b6bd0fea13fb40c6c16374052d5adb6d (patch)
treeb8a24e6870e818e61d585f4c71ae6346d8ab2d07
parent89a21c96c05dd89ff2d2bd5926d0f98c6ef0db9b (diff)
parent5e0858d13fb9343e53b03c93739b87fdd6087ecf (diff)
Merge pull request #1789 from Bond-009/deps
Update deps and add MultiThreading analyzer
-rw-r--r--Emby.Naming/Emby.Naming.csproj3
-rw-r--r--Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs25
-rw-r--r--Emby.Server.Implementations/Emby.Server.Implementations.csproj16
-rw-r--r--Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs17
-rw-r--r--Emby.Server.Implementations/Networking/NetworkManager.cs16
-rw-r--r--Emby.Server.Implementations/Updates/InstallationManager.cs84
-rw-r--r--Jellyfin.Server/Jellyfin.Server.csproj9
-rw-r--r--MediaBrowser.Common/MediaBrowser.Common.csproj2
-rw-r--r--MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj2
-rw-r--r--MediaBrowser.Model/MediaBrowser.Model.csproj2
-rw-r--r--MediaBrowser.Providers/MediaBrowser.Providers.csproj6
-rw-r--r--jellyfin.ruleset2
12 files changed, 106 insertions, 78 deletions
diff --git a/Emby.Naming/Emby.Naming.csproj b/Emby.Naming/Emby.Naming.csproj
index fca0aa1b3..a23fa3df7 100644
--- a/Emby.Naming/Emby.Naming.csproj
+++ b/Emby.Naming/Emby.Naming.csproj
@@ -24,8 +24,9 @@
<!-- Code analysers-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4" />
- <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" />
+ <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
+ <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" />
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
index 4832c19c4..7ec5252d0 100644
--- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
+++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
@@ -35,7 +35,7 @@ namespace Emby.Server.Implementations.AppBase
/// <summary>
/// The _configuration sync lock.
/// </summary>
- private object _configurationSyncLock = new object();
+ private readonly object _configurationSyncLock = new object();
/// <summary>
/// The _configuration.
@@ -98,16 +98,31 @@ namespace Emby.Server.Implementations.AppBase
public IApplicationPaths CommonApplicationPaths { get; private set; }
/// <summary>
- /// Gets the system configuration
+ /// Gets the system configuration.
/// </summary>
/// <value>The configuration.</value>
public BaseApplicationConfiguration CommonConfiguration
{
get
{
- // Lazy load
- LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationLoaded, ref _configurationSyncLock, () => (BaseApplicationConfiguration)ConfigurationHelper.GetXmlConfiguration(ConfigurationType, CommonApplicationPaths.SystemConfigurationFilePath, XmlSerializer));
- return _configuration;
+ if (_configurationLoaded)
+ {
+ return _configuration;
+ }
+
+ lock (_configurationSyncLock)
+ {
+ if (_configurationLoaded)
+ {
+ return _configuration;
+ }
+
+ _configuration = (BaseApplicationConfiguration)ConfigurationHelper.GetXmlConfiguration(ConfigurationType, CommonApplicationPaths.SystemConfigurationFilePath, XmlSerializer);
+
+ _configurationLoaded = true;
+
+ return _configuration;
+ }
}
protected set
{
diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
index ea4444268..d6ca19e3f 100644
--- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj
+++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\Emby.Naming\Emby.Naming.csproj" />
@@ -29,9 +29,9 @@
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.2.1" />
- <PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
- <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
- <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.2.0" />
+ <PackageReference Include="Microsoft.Extensions.Logging" Version="3.0.0" />
+ <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.0.0" />
<PackageReference Include="ServiceStack.Text.Core" Version="5.6.0" />
<PackageReference Include="sharpcompress" Version="0.24.0" />
<PackageReference Include="SQLitePCL.pretty.netstandard" Version="2.0.1" />
@@ -47,16 +47,12 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
- <PropertyGroup>
- <!-- We need at least C# 7.3 to compare tuples-->
- <LangVersion>latest</LangVersion>
- </PropertyGroup>
-
<!-- Code analysers-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4" />
- <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" />
+ <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
+ <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" />
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
diff --git a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs
index f26a70586..d55dc2f18 100644
--- a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs
+++ b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs
@@ -27,6 +27,11 @@ namespace Emby.Server.Implementations.EntryPoints
private NatManager _natManager;
+ private readonly object _createdRulesLock = new object();
+ private List<string> _createdRules = new List<string>();
+ private readonly object _usnsHandledLock = new object();
+ private List<string> _usnsHandled = new List<string>();
+
public ExternalPortForwarding(ILoggerFactory loggerFactory, IServerApplicationHost appHost, IServerConfigurationManager config, IDeviceDiscovery deviceDiscovery, IHttpClient httpClient)
{
_logger = loggerFactory.CreateLogger("PortMapper");
@@ -127,12 +132,13 @@ namespace Emby.Server.Implementations.EntryPoints
return;
}
- lock (_usnsHandled)
+ lock (_usnsHandledLock)
{
if (_usnsHandled.Contains(identifier))
{
return;
}
+
_usnsHandled.Add(identifier);
}
@@ -186,11 +192,12 @@ namespace Emby.Server.Implementations.EntryPoints
private void ClearCreatedRules(object state)
{
- lock (_createdRules)
+ lock (_createdRulesLock)
{
_createdRules.Clear();
}
- lock (_usnsHandled)
+
+ lock (_usnsHandledLock)
{
_usnsHandled.Clear();
}
@@ -216,8 +223,6 @@ namespace Emby.Server.Implementations.EntryPoints
}
}
- private List<string> _createdRules = new List<string>();
- private List<string> _usnsHandled = new List<string>();
private async void CreateRules(INatDevice device)
{
if (_disposed)
@@ -231,7 +236,7 @@ namespace Emby.Server.Implementations.EntryPoints
var addressString = address.ToString();
- lock (_createdRules)
+ lock (_createdRulesLock)
{
if (!_createdRules.Contains(addressString))
{
diff --git a/Emby.Server.Implementations/Networking/NetworkManager.cs b/Emby.Server.Implementations/Networking/NetworkManager.cs
index 7d85a0666..d948dad68 100644
--- a/Emby.Server.Implementations/Networking/NetworkManager.cs
+++ b/Emby.Server.Implementations/Networking/NetworkManager.cs
@@ -20,6 +20,9 @@ namespace Emby.Server.Implementations.Networking
private IPAddress[] _localIpAddresses;
private readonly object _localIpAddressSyncLock = new object();
+ private readonly object _subnetLookupLock = new object();
+ private Dictionary<string, List<string>> _subnetLookup = new Dictionary<string, List<string>>(StringComparer.Ordinal);
+
public NetworkManager(ILogger<NetworkManager> logger)
{
_logger = logger;
@@ -28,10 +31,10 @@ namespace Emby.Server.Implementations.Networking
NetworkChange.NetworkAvailabilityChanged += OnNetworkAvailabilityChanged;
}
- public Func<string[]> LocalSubnetsFn { get; set; }
-
public event EventHandler NetworkChanged;
+ public Func<string[]> LocalSubnetsFn { get; set; }
+
private void OnNetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
{
_logger.LogDebug("NetworkAvailabilityChanged");
@@ -179,10 +182,9 @@ namespace Emby.Server.Implementations.Networking
return false;
}
- private Dictionary<string, List<string>> _subnetLookup = new Dictionary<string, List<string>>(StringComparer.Ordinal);
private List<string> GetSubnets(string endpointFirstPart)
{
- lock (_subnetLookup)
+ lock (_subnetLookupLock)
{
if (_subnetLookup.TryGetValue(endpointFirstPart, out var subnets))
{
@@ -200,7 +202,11 @@ namespace Emby.Server.Implementations.Networking
int subnet_Test = 0;
foreach (string part in unicastIPAddressInformation.IPv4Mask.ToString().Split('.'))
{
- if (part.Equals("0")) break;
+ if (part.Equals("0", StringComparison.Ordinal))
+ {
+ break;
+ }
+
subnet_Test++;
}
diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs
index 0c0c77cda..a1e2f9079 100644
--- a/Emby.Server.Implementations/Updates/InstallationManager.cs
+++ b/Emby.Server.Implementations/Updates/InstallationManager.cs
@@ -28,43 +28,10 @@ namespace Emby.Server.Implementations.Updates
/// </summary>
public class InstallationManager : IInstallationManager
{
- public event EventHandler<InstallationEventArgs> PackageInstalling;
- public event EventHandler<InstallationEventArgs> PackageInstallationCompleted;
- public event EventHandler<InstallationFailedEventArgs> PackageInstallationFailed;
- public event EventHandler<InstallationEventArgs> PackageInstallationCancelled;
-
- /// <summary>
- /// The current installations
- /// </summary>
- private List<(InstallationInfo info, CancellationTokenSource token)> _currentInstallations { get; set; }
-
/// <summary>
- /// The completed installations
- /// </summary>
- private ConcurrentBag<InstallationInfo> _completedInstallationsInternal;
-
- public IEnumerable<InstallationInfo> CompletedInstallations => _completedInstallationsInternal;
-
- /// <summary>
- /// Occurs when [plugin uninstalled].
- /// </summary>
- public event EventHandler<GenericEventArgs<IPlugin>> PluginUninstalled;
-
- /// <summary>
- /// Occurs when [plugin updated].
- /// </summary>
- public event EventHandler<GenericEventArgs<(IPlugin, PackageVersionInfo)>> PluginUpdated;
-
- /// <summary>
- /// Occurs when [plugin updated].
- /// </summary>
- public event EventHandler<GenericEventArgs<PackageVersionInfo>> PluginInstalled;
-
- /// <summary>
- /// The _logger
+ /// The _logger.
/// </summary>
private readonly ILogger _logger;
-
private readonly IApplicationPaths _appPaths;
private readonly IHttpClient _httpClient;
private readonly IJsonSerializer _jsonSerializer;
@@ -79,6 +46,18 @@ namespace Emby.Server.Implementations.Updates
private readonly IZipClient _zipClient;
+ private readonly object _currentInstallationsLock = new object();
+
+ /// <summary>
+ /// The current installations.
+ /// </summary>
+ private List<(InstallationInfo info, CancellationTokenSource token)> _currentInstallations;
+
+ /// <summary>
+ /// The completed installations.
+ /// </summary>
+ private ConcurrentBag<InstallationInfo> _completedInstallationsInternal;
+
public InstallationManager(
ILogger<InstallationManager> logger,
IApplicationHost appHost,
@@ -107,6 +86,31 @@ namespace Emby.Server.Implementations.Updates
_zipClient = zipClient;
}
+ public event EventHandler<InstallationEventArgs> PackageInstalling;
+
+ public event EventHandler<InstallationEventArgs> PackageInstallationCompleted;
+
+ public event EventHandler<InstallationFailedEventArgs> PackageInstallationFailed;
+
+ public event EventHandler<InstallationEventArgs> PackageInstallationCancelled;
+
+ /// <summary>
+ /// Occurs when a plugin is uninstalled.
+ /// </summary>
+ public event EventHandler<GenericEventArgs<IPlugin>> PluginUninstalled;
+
+ /// <summary>
+ /// Occurs when a plugin plugin is updated.
+ /// </summary>
+ public event EventHandler<GenericEventArgs<(IPlugin, PackageVersionInfo)>> PluginUpdated;
+
+ /// <summary>
+ /// Occurs when a plugin plugin is installed.
+ /// </summary>
+ public event EventHandler<GenericEventArgs<PackageVersionInfo>> PluginInstalled;
+
+ public IEnumerable<InstallationInfo> CompletedInstallations => _completedInstallationsInternal;
+
/// <summary>
/// Gets all available packages.
/// </summary>
@@ -330,7 +334,7 @@ namespace Emby.Server.Implementations.Updates
var tuple = (installationInfo, innerCancellationTokenSource);
// Add it to the in-progress list
- lock (_currentInstallations)
+ lock (_currentInstallationsLock)
{
_currentInstallations.Add(tuple);
}
@@ -349,7 +353,7 @@ namespace Emby.Server.Implementations.Updates
{
await InstallPackageInternal(package, linkedToken).ConfigureAwait(false);
- lock (_currentInstallations)
+ lock (_currentInstallationsLock)
{
_currentInstallations.Remove(tuple);
}
@@ -360,7 +364,7 @@ namespace Emby.Server.Implementations.Updates
}
catch (OperationCanceledException)
{
- lock (_currentInstallations)
+ lock (_currentInstallationsLock)
{
_currentInstallations.Remove(tuple);
}
@@ -375,7 +379,7 @@ namespace Emby.Server.Implementations.Updates
{
_logger.LogError(ex, "Package installation failed");
- lock (_currentInstallations)
+ lock (_currentInstallationsLock)
{
_currentInstallations.Remove(tuple);
}
@@ -535,7 +539,7 @@ namespace Emby.Server.Implementations.Updates
/// <inheritdoc/>
public bool CancelInstallation(Guid id)
{
- lock (_currentInstallations)
+ lock (_currentInstallationsLock)
{
var install = _currentInstallations.Find(x => x.Item1.Id == id);
if (install == default((InstallationInfo, CancellationTokenSource)))
@@ -563,7 +567,7 @@ namespace Emby.Server.Implementations.Updates
{
if (dispose)
{
- lock (_currentInstallations)
+ lock (_currentInstallationsLock)
{
foreach (var tuple in _currentInstallations)
{
diff --git a/Jellyfin.Server/Jellyfin.Server.csproj b/Jellyfin.Server/Jellyfin.Server.csproj
index efdb75f98..4238d7fe3 100644
--- a/Jellyfin.Server/Jellyfin.Server.csproj
+++ b/Jellyfin.Server/Jellyfin.Server.csproj
@@ -9,8 +9,6 @@
</PropertyGroup>
<PropertyGroup>
- <!-- We need at least C# 7.1 for async main-->
- <LangVersion>latest</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
@@ -25,8 +23,9 @@
<!-- Code analyzers-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4" />
- <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" />
+ <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
+ <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" />
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
@@ -35,8 +34,8 @@
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.6.0" />
- <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.4" />
- <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
+ <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.0" />
diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj
index cf3f6c2a4..ec98400c8 100644
--- a/MediaBrowser.Common/MediaBrowser.Common.csproj
+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj
@@ -12,7 +12,7 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
+ <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.0" />
</ItemGroup>
diff --git a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj
index 264f31f3c..ad07fdd8e 100644
--- a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj
+++ b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj
@@ -18,7 +18,7 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
+ <PackageReference Include="System.Text.Encoding.CodePages" Version="4.6.0" />
<PackageReference Include="UTF.Unknown" Version="2.1.0" />
</ItemGroup>
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index 3ed319a0d..bd4eeea18 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -15,7 +15,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
- <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
+ <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.0.0" />
<PackageReference Include="System.Text.Json" Version="4.6.0" />
</ItemGroup>
diff --git a/MediaBrowser.Providers/MediaBrowser.Providers.csproj b/MediaBrowser.Providers/MediaBrowser.Providers.csproj
index c7ecc59c9..ec160a848 100644
--- a/MediaBrowser.Providers/MediaBrowser.Providers.csproj
+++ b/MediaBrowser.Providers/MediaBrowser.Providers.csproj
@@ -11,8 +11,8 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
- <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.2.0" />
+ <PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.0.0" />
<PackageReference Include="OptimizedPriorityQueue" Version="4.2.0" />
<PackageReference Include="PlaylistsNET" Version="1.0.4" />
<PackageReference Include="TvDbSharper" Version="2.0.0" />
@@ -28,5 +28,5 @@
<!-- We need at least C# 7.1 -->
<LangVersion>latest</LangVersion>
</PropertyGroup>
-
+
</Project>
diff --git a/jellyfin.ruleset b/jellyfin.ruleset
index e259131b0..16d68567c 100644
--- a/jellyfin.ruleset
+++ b/jellyfin.ruleset
@@ -10,6 +10,8 @@
<Rule Id="SA1101" Action="None" />
<!-- disable warning SA1108: Block statements should not contain embedded comments -->
<Rule Id="SA1108" Action="None" />
+ <!-- disable warning SA1128:: Put constructor initializers on their own line -->
+ <Rule Id="SA1128" Action="None" />
<!-- disable warning SA1130: Use lambda syntax -->
<Rule Id="SA1130" Action="None" />
<!-- disable warning SA1200: 'using' directive must appear within a namespace declaration -->