aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Core
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Core')
-rw-r--r--Emby.Server.Core/EntryPoints/ExternalPortForwarding.cs22
-rw-r--r--Emby.Server.Core/IO/LibraryMonitor.cs7
2 files changed, 29 insertions, 0 deletions
diff --git a/Emby.Server.Core/EntryPoints/ExternalPortForwarding.cs b/Emby.Server.Core/EntryPoints/ExternalPortForwarding.cs
index b75de2ff4..4fbcf0042 100644
--- a/Emby.Server.Core/EntryPoints/ExternalPortForwarding.cs
+++ b/Emby.Server.Core/EntryPoints/ExternalPortForwarding.cs
@@ -106,6 +106,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 +174,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 +195,11 @@ namespace Emby.Server.Core.EntryPoints
void NatUtility_DeviceFound(object sender, DeviceEventArgs e)
{
+ if (_disposed)
+ {
+ return;
+ }
+
try
{
var device = e.Device;
@@ -210,6 +225,11 @@ namespace Emby.Server.Core.EntryPoints
private List<string> _usnsHandled = new List<string>();
private 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
@@ -249,8 +269,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..87b70d047 100644
--- a/Emby.Server.Core/IO/LibraryMonitor.cs
+++ b/Emby.Server.Core/IO/LibraryMonitor.cs
@@ -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