aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-01-02 14:36:54 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-01-02 14:36:54 -0500
commit111324a726c465f40e96a13bea7ba1bd5e164b9e (patch)
treed43ab68be071e47271fe463b3791fb561c43d781
parent14af8211ebe84a75df7692819e5e670eaef5cd62 (diff)
improve dispose
-rw-r--r--Emby.Server.Core/EntryPoints/ExternalPortForwarding.cs22
1 files changed, 22 insertions, 0 deletions
diff --git a/Emby.Server.Core/EntryPoints/ExternalPortForwarding.cs b/Emby.Server.Core/EntryPoints/ExternalPortForwarding.cs
index b75de2ff4f..4fbcf0042c 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();
}