From 09fc300508ae02fc4373dd1b8c5b72664fb0ea33 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Fri, 25 Dec 2020 19:49:44 +0530 Subject: [PATCH] ignoring ObjectDisposedException when server stops. --- DnsServerCore/Dhcp/DhcpServer.cs | 2 +- DnsServerCore/Dns/DnsServer.cs | 4 ++++ DnsServerCore/WebService.cs | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/DnsServerCore/Dhcp/DhcpServer.cs b/DnsServerCore/Dhcp/DhcpServer.cs index df670285..c26144fb 100644 --- a/DnsServerCore/Dhcp/DhcpServer.cs +++ b/DnsServerCore/Dhcp/DhcpServer.cs @@ -202,7 +202,7 @@ namespace DnsServerCore.Dhcp } catch (ObjectDisposedException) { - //socket disposed + //server stopped } catch (SocketException ex) { diff --git a/DnsServerCore/Dns/DnsServer.cs b/DnsServerCore/Dns/DnsServer.cs index 87631796..5a9c7d96 100644 --- a/DnsServerCore/Dns/DnsServer.cs +++ b/DnsServerCore/Dns/DnsServer.cs @@ -374,6 +374,10 @@ namespace DnsServerCore.Dns if (log != null) log.Write(localEP, protocol, ex); } + catch (ObjectDisposedException) + { + //server stopped + } catch (Exception ex) { if ((_state == ServiceState.Stopping) || (_state == ServiceState.Stopped)) diff --git a/DnsServerCore/WebService.cs b/DnsServerCore/WebService.cs index 3f54b543..c217b264 100644 --- a/DnsServerCore/WebService.cs +++ b/DnsServerCore/WebService.cs @@ -217,6 +217,10 @@ namespace DnsServerCore _log.Write(ex); } + catch (ObjectDisposedException) + { + //web service stopped + } catch (Exception ex) { if ((_state == ServiceState.Stopping) || (_state == ServiceState.Stopped)) @@ -244,6 +248,10 @@ namespace DnsServerCore _log.Write(ex); } + catch (ObjectDisposedException) + { + //web service stopped + } catch (Exception ex) { if ((_state == ServiceState.Stopping) || (_state == ServiceState.Stopped))