diff options
| author | Bond_009 <bond.009@outlook.com> | 2019-11-02 10:31:14 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2019-11-02 10:31:27 +0100 |
| commit | 210af0e73e6370b037105ed89776e86217fb873a (patch) | |
| tree | a7de7c1d7497efe51d265f7e5516926ba8ad39d6 | |
| parent | 558baeac48abfe6ee82b94cb2ee664160677c8c7 (diff) | |
Properly remove event handler
| -rw-r--r-- | Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs index 7cf850932..08041eb59 100644 --- a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs +++ b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs @@ -65,23 +65,20 @@ namespace Emby.Server.Implementations.EntryPoints .ToString(); } - private async void OnConfigurationUpdated(object sender, EventArgs e) + private void OnConfigurationUpdated(object sender, EventArgs e) { if (!string.Equals(_lastConfigIdentifier, GetConfigIdentifier(), StringComparison.OrdinalIgnoreCase)) { Stop(); - await RunAsync().ConfigureAwait(false); + Start(); } } /// <inheritdoc /> public Task RunAsync() { - if (_config.Configuration.EnableUPnP && _config.Configuration.EnableRemoteAccess) - { - Start(); - } + Start(); _config.ConfigurationUpdated += OnConfigurationUpdated; @@ -90,6 +87,11 @@ namespace Emby.Server.Implementations.EntryPoints private void Start() { + if (!_config.Configuration.EnableUPnP || !_config.Configuration.EnableRemoteAccess) + { + return; + } + _logger.LogDebug("Starting NAT discovery"); NatUtility.DeviceFound += OnNatUtilityDeviceFound; @@ -214,6 +216,8 @@ namespace Emby.Server.Implementations.EntryPoints return; } + _config.ConfigurationUpdated -= OnConfigurationUpdated; + Stop(); _timer = null; |
