diff options
Diffstat (limited to 'Emby.Server.Core')
| -rw-r--r-- | Emby.Server.Core/ApplicationHost.cs | 10 | ||||
| -rw-r--r-- | Emby.Server.Core/EntryPoints/ExternalPortForwarding.cs | 39 | ||||
| -rw-r--r-- | Emby.Server.Core/IO/LibraryMonitor.cs | 9 |
3 files changed, 51 insertions, 7 deletions
diff --git a/Emby.Server.Core/ApplicationHost.cs b/Emby.Server.Core/ApplicationHost.cs index 215ac8492..b9412d0fb 100644 --- a/Emby.Server.Core/ApplicationHost.cs +++ b/Emby.Server.Core/ApplicationHost.cs @@ -326,6 +326,8 @@ namespace Emby.Server.Core } } + public abstract bool IsRunningAsService { get; } + private Assembly GetAssembly(Type type) { return type.GetTypeInfo().Assembly; @@ -489,7 +491,8 @@ namespace Emby.Server.Core { var migrations = new List<IVersionMigration> { - new LibraryScanMigration(ServerConfigurationManager, TaskManager) + new LibraryScanMigration(ServerConfigurationManager, TaskManager), + new GuideMigration(ServerConfigurationManager, TaskManager) }; foreach (var task in migrations) @@ -1247,7 +1250,6 @@ namespace Emby.Server.Core HasUpdateAvailable = HasUpdateAvailable, SupportsAutoRunAtStartup = SupportsAutoRunAtStartup, TranscodingTempPath = ApplicationPaths.TranscodingTempPath, - IsRunningAsService = IsRunningAsService, SupportsRunningAsService = SupportsRunningAsService, ServerName = FriendlyName, LocalAddress = localAddress, @@ -1477,6 +1479,10 @@ namespace Emby.Server.Core { AuthorizeServer(); } + catch (NotImplementedException) + { + + } catch (Exception ex) { Logger.ErrorException("Error authorizing server", ex); diff --git a/Emby.Server.Core/EntryPoints/ExternalPortForwarding.cs b/Emby.Server.Core/EntryPoints/ExternalPortForwarding.cs index b75de2ff4..eb3a71465 100644 --- a/Emby.Server.Core/EntryPoints/ExternalPortForwarding.cs +++ b/Emby.Server.Core/EntryPoints/ExternalPortForwarding.cs @@ -11,6 +11,7 @@ using MediaBrowser.Model.Events; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Threading; using Mono.Nat; +using System.Threading.Tasks; namespace Emby.Server.Core.EntryPoints { @@ -106,6 +107,11 @@ namespace Emby.Server.Core.EntryPoints private async void _deviceDiscovery_DeviceDiscovered(object sender, GenericEventArgs<UpnpDeviceInfo> e) { + if (_disposed) + { + return; + } + var info = e.Argument; string usn; @@ -169,6 +175,11 @@ namespace Emby.Server.Core.EntryPoints return; } + if (_disposed) + { + return; + } + _logger.Debug("Calling Nat.Handle on " + identifier); NatUtility.Handle(localAddress, info, endpoint, NatProtocol.Upnp); } @@ -185,6 +196,11 @@ namespace Emby.Server.Core.EntryPoints void NatUtility_DeviceFound(object sender, DeviceEventArgs e) { + if (_disposed) + { + return; + } + try { var device = e.Device; @@ -208,8 +224,13 @@ namespace Emby.Server.Core.EntryPoints private List<string> _createdRules = new List<string>(); private List<string> _usnsHandled = new List<string>(); - private void CreateRules(INatDevice device) + private async void CreateRules(INatDevice device) { + if (_disposed) + { + throw new ObjectDisposedException("PortMapper"); + } + // On some systems the device discovered event seems to fire repeatedly // This check will help ensure we're not trying to port map the same device over and over @@ -219,12 +240,16 @@ namespace Emby.Server.Core.EntryPoints { _createdRules.Add(address); - CreatePortMap(device, _appHost.HttpPort, _config.Configuration.PublicPort); - CreatePortMap(device, _appHost.HttpsPort, _config.Configuration.PublicHttpsPort); + var success = await CreatePortMap(device, _appHost.HttpPort, _config.Configuration.PublicPort).ConfigureAwait(false); + + if (success) + { + await CreatePortMap(device, _appHost.HttpsPort, _config.Configuration.PublicHttpsPort).ConfigureAwait(false); + } } } - private async void CreatePortMap(INatDevice device, int privatePort, int publicPort) + private async Task<bool> CreatePortMap(INatDevice device, int privatePort, int publicPort) { _logger.Debug("Creating port map on port {0}", privatePort); @@ -235,10 +260,14 @@ namespace Emby.Server.Core.EntryPoints Description = _appHost.Name }).ConfigureAwait(false); + + return true; } catch (Exception ex) { _logger.Error("Error creating port map: " + ex.Message); + + return false; } } @@ -249,8 +278,10 @@ namespace Emby.Server.Core.EntryPoints _logger.Debug("NAT device lost: {0}", device.LocalAddress.ToString()); } + private bool _disposed = false; public void Dispose() { + _disposed = true; DisposeNat(); } diff --git a/Emby.Server.Core/IO/LibraryMonitor.cs b/Emby.Server.Core/IO/LibraryMonitor.cs index 6ed096f44..f0ecb9d89 100644 --- a/Emby.Server.Core/IO/LibraryMonitor.cs +++ b/Emby.Server.Core/IO/LibraryMonitor.cs @@ -87,7 +87,7 @@ namespace Emby.Server.Core.IO public bool IsPathLocked(string path) { var lockedPaths = _tempIgnoredPaths.Keys.ToList(); - return lockedPaths.Any(i => string.Equals(i, path, StringComparison.OrdinalIgnoreCase) || _fileSystem.ContainsSubPath(i, path)); + return lockedPaths.Any(i => _fileSystem.AreEqual(i, path) || _fileSystem.ContainsSubPath(i, path)); } public async void ReportFileSystemChangeComplete(string path, bool refreshPath) @@ -288,6 +288,13 @@ namespace Emby.Server.Core.IO { try { + if (!_fileSystem.DirectoryExists(path)) + { + // Seeing a crash in the mono runtime due to an exception being thrown on a different thread + Logger.Info("Skipping realtime monitor for {0} because the path does not exist", path); + return; + } + var newWatcher = new FileSystemWatcher(path, "*") { IncludeSubdirectories = true |
