From 97d918e03ae0db6e8fb3f5ddcec74ce562799080 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 10 Dec 2018 17:25:18 -0800 Subject: [PATCH] Do 0-byte reads on MacOS (#4560) Underlying corefx issue has been fixed --- .../src/Internal/SocketConnection.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Servers/Kestrel/Transport.Sockets/src/Internal/SocketConnection.cs b/src/Servers/Kestrel/Transport.Sockets/src/Internal/SocketConnection.cs index 8f5a3ca0a6..e84a7e69ce 100644 --- a/src/Servers/Kestrel/Transport.Sockets/src/Internal/SocketConnection.cs +++ b/src/Servers/Kestrel/Transport.Sockets/src/Internal/SocketConnection.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// 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; @@ -156,12 +156,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal { while (true) { - // MacOS blocked on https://github.com/dotnet/corefx/issues/31766 - if (!IsMacOS) - { - // Wait for data before allocating a buffer. - await _receiver.WaitForDataAsync(); - } + // Wait for data before allocating a buffer. + await _receiver.WaitForDataAsync(); // Ensure we have some reasonable amount of buffer space var buffer = Input.GetMemory(MinAllocBufferSize); @@ -215,7 +211,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal shutdownReason = new ConnectionResetException(ex.Message, ex);; _trace.ConnectionReset(ConnectionId); } - catch (Exception ex) + catch (Exception ex) when ((ex is SocketException socketEx && IsConnectionAbortError(socketEx.SocketErrorCode)) || ex is ObjectDisposedException) {