From d42ad0673d003272c2d928fe40998f5aac0d010d Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Tue, 9 Jul 2024 20:40:22 +0100 Subject: [PATCH] Handle ERROR_OPERATION_ABORTED result when a transfer is cancelled. Seen on Windows 10 while shutting down a bulk Queue. --- src/platform/windows_winusb/transfer.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/platform/windows_winusb/transfer.rs b/src/platform/windows_winusb/transfer.rs index 052b076..631b23d 100644 --- a/src/platform/windows_winusb/transfer.rs +++ b/src/platform/windows_winusb/transfer.rs @@ -14,8 +14,8 @@ use windows_sys::Win32::{ }, Foundation::{ GetLastError, ERROR_DEVICE_NOT_CONNECTED, ERROR_FILE_NOT_FOUND, ERROR_GEN_FAILURE, - ERROR_IO_PENDING, ERROR_NOT_FOUND, ERROR_NO_SUCH_DEVICE, ERROR_REQUEST_ABORTED, - ERROR_SEM_TIMEOUT, ERROR_TIMEOUT, FALSE, TRUE, WIN32_ERROR, + ERROR_IO_PENDING, ERROR_NOT_FOUND, ERROR_NO_SUCH_DEVICE, ERROR_OPERATION_ABORTED, + ERROR_REQUEST_ABORTED, ERROR_SEM_TIMEOUT, ERROR_TIMEOUT, FALSE, TRUE, WIN32_ERROR, }, System::IO::{CancelIoEx, OVERLAPPED}, }; @@ -338,7 +338,9 @@ pub(super) fn handle_event(completion: *mut OVERLAPPED) { pub(crate) fn map_error(err: WIN32_ERROR) -> TransferError { match err { ERROR_GEN_FAILURE => TransferError::Stall, - ERROR_REQUEST_ABORTED | ERROR_TIMEOUT | ERROR_SEM_TIMEOUT => TransferError::Cancelled, + ERROR_REQUEST_ABORTED | ERROR_TIMEOUT | ERROR_SEM_TIMEOUT | ERROR_OPERATION_ABORTED => { + TransferError::Cancelled + } ERROR_FILE_NOT_FOUND | ERROR_DEVICE_NOT_CONNECTED | ERROR_NO_SUCH_DEVICE => { TransferError::Disconnected }