Handle EPIPE like ECONNRESET on Linux (#2112)
This commit is contained in:
parent
9dfffd14bb
commit
733ac1efab
|
|
@ -162,7 +162,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
|||
handle.Libuv.Check(status, out var uvError);
|
||||
|
||||
// Log connection resets at a lower (Debug) level.
|
||||
if (status == LibuvConstants.ECONNRESET)
|
||||
if (LibuvConstants.IsConnectionReset(status))
|
||||
{
|
||||
Log.ConnectionReset(ConnectionId);
|
||||
error = new ConnectionResetException(uvError.Message, uvError);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// 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.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
||||
|
|
@ -13,6 +14,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
|||
public static readonly int? ECONNRESET = GetECONNRESET();
|
||||
public static readonly int? EADDRINUSE = GetEADDRINUSE();
|
||||
public static readonly int? ENOTSUP = GetENOTSUP();
|
||||
public static readonly int? EPIPE = GetEPIPE();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsConnectionReset(int errno)
|
||||
{
|
||||
return errno == ECONNRESET || errno == EPIPE;
|
||||
}
|
||||
|
||||
private static int? GetECONNRESET()
|
||||
{
|
||||
|
|
@ -31,6 +39,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
|||
return null;
|
||||
}
|
||||
|
||||
private static int? GetEPIPE()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
return -32;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int? GetEADDRINUSE()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
|||
else
|
||||
{
|
||||
// Log connection resets at a lower (Debug) level.
|
||||
if (status == LibuvConstants.ECONNRESET)
|
||||
if (LibuvConstants.IsConnectionReset(status))
|
||||
{
|
||||
_log.ConnectionReset(_connectionId);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue