From 9a06bf39ab1736c4739b13b93a552ec83dcb3b35 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Wed, 18 May 2016 22:11:10 -0700 Subject: [PATCH] Move ECONNRESET value check to server initialization. --- .../Http/Connection.cs | 10 +--------- .../Infrastructure/Constants.cs | 1 - .../KestrelServer.cs | 5 +++++ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Http/Connection.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Http/Connection.cs index be6b7a347e..1bfd927772 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Http/Connection.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Http/Connection.cs @@ -40,8 +40,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http private ConnectionState _connectionState; private TaskCompletionSource _socketClosedTcs; - bool _eConnResetChecked = false; - public Connection(ListenerContext context, UvStreamHandle socket) : base(context) { _socket = socket; @@ -202,7 +200,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http if (_socketClosedTcs != null) { // This is always waited on synchronously, so it's safe to - // call on the libuv thread. + // call on the libuv thread. _socketClosedTcs.TrySetResult(null); } } @@ -274,12 +272,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http return; } - if (!_eConnResetChecked && !Constants.ECONNRESET.HasValue) - { - Log.LogWarning("Unable to determine ECONNRESET value on this platform."); - _eConnResetChecked = true; - } - var normalRead = status > 0; var normalDone = status == Constants.ECONNRESET || status == Constants.EOF; var errorDone = !(normalDone || normalRead); diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/Constants.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/Constants.cs index dcbd4cb5f3..b7dcc01a41 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/Constants.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/Constants.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using Microsoft.Extensions.PlatformAbstractions; namespace Microsoft.AspNetCore.Server.Kestrel.Infrastructure diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/KestrelServer.cs b/src/Microsoft.AspNetCore.Server.Kestrel/KestrelServer.cs index 19068784a4..35b134d152 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/KestrelServer.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/KestrelServer.cs @@ -94,6 +94,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel "ThreadCount must be positive."); } + if (!Constants.ECONNRESET.HasValue) + { + _logger.LogWarning("Unable to determine ECONNRESET value on this platform."); + } + engine.Start(threadCount); var atLeastOneListener = false;