Skip to content

Commit

Permalink
Handle ERROR_OPERATION_ABORTED result when a transfer is cancelled.
Browse files Browse the repository at this point in the history
Seen on Windows 10 while shutting down a bulk Queue.
  • Loading branch information
martinling committed Jul 9, 2024
1 parent 50e022b commit d42ad06
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/platform/windows_winusb/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit d42ad06

Please sign in to comment.