diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/ListenerSecondary.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/ListenerSecondary.cs index 1a6ea958b4..e11729200f 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/ListenerSecondary.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/ListenerSecondary.cs @@ -138,8 +138,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http return; } - var connection = new Connection(this, acceptSocket); - connection.Start(); + try + { + var connection = new Connection(this, acceptSocket); + connection.Start(); + } + catch (UvException ex) + { + Log.LogError(0, ex, "ListenerSecondary.OnConnection"); + acceptSocket.Dispose(); + } } /// diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/PipeListener.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/PipeListener.cs index cb79dadd07..0b01438870 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/PipeListener.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/PipeListener.cs @@ -47,7 +47,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http { Log.LogError(0, ex, "PipeListener.OnConnection"); acceptSocket.Dispose(); - return; } } } diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/PipeListenerPrimary.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/PipeListenerPrimary.cs index 65b9521f1f..3011a26616 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/PipeListenerPrimary.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/PipeListenerPrimary.cs @@ -47,7 +47,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http { Log.LogError(0, ex, "ListenerPrimary.OnConnection"); acceptSocket.Dispose(); - return; } } } diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/TcpListener.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/TcpListener.cs index 353afad609..8f3b664105 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/TcpListener.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/TcpListener.cs @@ -53,7 +53,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http { Log.LogError(0, ex, "TcpListener.OnConnection"); acceptSocket.Dispose(); - return; } } } diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/TcpListenerPrimary.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/TcpListenerPrimary.cs index dc47a375c5..b442deb42e 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/TcpListenerPrimary.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/TcpListenerPrimary.cs @@ -48,13 +48,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http acceptSocket.NoDelay(ServerOptions.NoDelay); listenSocket.Accept(acceptSocket); DispatchConnection(acceptSocket); - } catch (UvException ex) { Log.LogError(0, ex, "TcpListenerPrimary.OnConnection"); acceptSocket.Dispose(); - return; } } }