mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
improve dispose
This commit is contained in:
parent
14af8211eb
commit
111324a726
@ -106,6 +106,11 @@ namespace Emby.Server.Core.EntryPoints
|
|||||||
|
|
||||||
private async void _deviceDiscovery_DeviceDiscovered(object sender, GenericEventArgs<UpnpDeviceInfo> e)
|
private async void _deviceDiscovery_DeviceDiscovered(object sender, GenericEventArgs<UpnpDeviceInfo> e)
|
||||||
{
|
{
|
||||||
|
if (_disposed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var info = e.Argument;
|
var info = e.Argument;
|
||||||
|
|
||||||
string usn;
|
string usn;
|
||||||
@ -169,6 +174,11 @@ namespace Emby.Server.Core.EntryPoints
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_disposed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_logger.Debug("Calling Nat.Handle on " + identifier);
|
_logger.Debug("Calling Nat.Handle on " + identifier);
|
||||||
NatUtility.Handle(localAddress, info, endpoint, NatProtocol.Upnp);
|
NatUtility.Handle(localAddress, info, endpoint, NatProtocol.Upnp);
|
||||||
}
|
}
|
||||||
@ -185,6 +195,11 @@ namespace Emby.Server.Core.EntryPoints
|
|||||||
|
|
||||||
void NatUtility_DeviceFound(object sender, DeviceEventArgs e)
|
void NatUtility_DeviceFound(object sender, DeviceEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (_disposed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var device = e.Device;
|
var device = e.Device;
|
||||||
@ -210,6 +225,11 @@ namespace Emby.Server.Core.EntryPoints
|
|||||||
private List<string> _usnsHandled = new List<string>();
|
private List<string> _usnsHandled = new List<string>();
|
||||||
private void CreateRules(INatDevice device)
|
private void CreateRules(INatDevice device)
|
||||||
{
|
{
|
||||||
|
if (_disposed)
|
||||||
|
{
|
||||||
|
throw new ObjectDisposedException("PortMapper");
|
||||||
|
}
|
||||||
|
|
||||||
// On some systems the device discovered event seems to fire repeatedly
|
// 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
|
// 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());
|
_logger.Debug("NAT device lost: {0}", device.LocalAddress.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _disposed = false;
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
_disposed = true;
|
||||||
DisposeNat();
|
DisposeNat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user