Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.0] Fix reporting of an async IO timeout error on Windows (SerialPort) #81745

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ internal static partial class Interop
{
internal static class StatusOptions
{
// See the NT_SUCCESS macro in the Windows SDK, and
// https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values
internal static bool NT_SUCCESS(uint ntStatus) => (int)ntStatus >= 0;

// Error codes from ntstatus.h
internal const uint STATUS_SUCCESS = 0x00000000;
internal const uint STATUS_SOME_NOT_MAPPED = 0x00000107;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public static void Invoke(Event e)
// The NtStatus code for the operation is in the InternalLow field
uint ntStatus = (uint)(nint)e.nativeOverlapped->InternalLow;
uint errorCode = Interop.Errors.ERROR_SUCCESS;
if (ntStatus != Interop.StatusOptions.STATUS_SUCCESS)
if (!Interop.StatusOptions.NT_SUCCESS(ntStatus))
{
errorCode = Interop.NtDll.RtlNtStatusToDosError((int)ntStatus);
}
Expand Down