From b4632c273edf15f627df18d964baf5f4479c8285 Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Tue, 7 Jun 2016 17:07:14 -0700 Subject: [PATCH] Handle exceptions thrown from Connection.Start in ListenerSecondary - This is already done for primary listeners --- .../Internal/Http/ListenerSecondary.cs | 12 ++++++++++-- .../Internal/Http/PipeListener.cs | 1 - .../Internal/Http/PipeListenerPrimary.cs | 1 - .../Internal/Http/TcpListener.cs | 1 - .../Internal/Http/TcpListenerPrimary.cs | 2 -- 5 files changed, 10 insertions(+), 7 deletions(-) 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; } } }