Handle SocketError.ProtocolType as a connection reset on macOS (#2845)
* Handle SocketError.ProtocolType as a connection reset on macOS * Make IsConnectionResetError and IsConnectionAbortError stricter
This commit is contained in:
parent
e5a1101239
commit
fc3c2eef5e
|
|
@ -327,9 +327,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
|
|||
private static bool IsConnectionResetError(SocketError errorCode)
|
||||
{
|
||||
// A connection reset can be reported as SocketError.ConnectionAborted on Windows.
|
||||
// ProtocolType can be removed once https://github.com/dotnet/corefx/issues/31927 is fixed.
|
||||
return errorCode == SocketError.ConnectionReset ||
|
||||
errorCode == SocketError.ConnectionAborted ||
|
||||
errorCode == SocketError.Shutdown;
|
||||
errorCode == SocketError.Shutdown ||
|
||||
(errorCode == SocketError.ConnectionAborted && IsWindows) ||
|
||||
(errorCode == SocketError.ProtocolType && IsMacOS);
|
||||
}
|
||||
|
||||
private static bool IsConnectionAbortError(SocketError errorCode)
|
||||
|
|
@ -337,7 +339,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
|
|||
// Calling Dispose after ReceiveAsync can cause an "InvalidArgument" error on *nix.
|
||||
return errorCode == SocketError.OperationAborted ||
|
||||
errorCode == SocketError.Interrupted ||
|
||||
errorCode == SocketError.InvalidArgument;
|
||||
(errorCode == SocketError.InvalidArgument && !IsWindows);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue