Skip to content

Commit

Permalink
fix(driver): add ERROR_PIPE_NOT_CONNECTED as Ok
Browse files Browse the repository at this point in the history
  • Loading branch information
Berrysoft committed Mar 15, 2024
1 parent 0098da3 commit c5e8d6f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 8 additions & 4 deletions compio-driver/src/iocp/cp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use windows_sys::Win32::{
Foundation::{
GetLastError, RtlNtStatusToDosError, ERROR_BAD_COMMAND, ERROR_BROKEN_PIPE,
ERROR_HANDLE_EOF, ERROR_IO_INCOMPLETE, ERROR_NO_DATA, ERROR_PIPE_CONNECTED,
FACILITY_NTWIN32, INVALID_HANDLE_VALUE, NTSTATUS, STATUS_PENDING, STATUS_SUCCESS,
WAIT_IO_COMPLETION,
ERROR_PIPE_NOT_CONNECTED, FACILITY_NTWIN32, INVALID_HANDLE_VALUE, NTSTATUS, STATUS_PENDING,
STATUS_SUCCESS, WAIT_IO_COMPLETION,
},
Storage::FileSystem::SetFileCompletionNotificationModes,
System::{
Expand Down Expand Up @@ -184,8 +184,12 @@ impl CompletionPort {
} else {
let error = unsafe { RtlNtStatusToDosError(overlapped.base.Internal as _) };
match error {
ERROR_IO_INCOMPLETE | ERROR_HANDLE_EOF | ERROR_BROKEN_PIPE
| ERROR_PIPE_CONNECTED | ERROR_NO_DATA => Ok(0),
ERROR_IO_INCOMPLETE
| ERROR_HANDLE_EOF
| ERROR_BROKEN_PIPE
| ERROR_PIPE_CONNECTED
| ERROR_PIPE_NOT_CONNECTED
| ERROR_NO_DATA => Ok(0),
_ => Err(io::Error::from_raw_os_error(error as _)),
}
};
Expand Down
9 changes: 7 additions & 2 deletions compio-driver/src/iocp/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ use windows_sys::{
Foundation::{
CloseHandle, GetLastError, ERROR_ACCESS_DENIED, ERROR_BROKEN_PIPE, ERROR_HANDLE_EOF,
ERROR_IO_INCOMPLETE, ERROR_IO_PENDING, ERROR_NOT_FOUND, ERROR_NO_DATA,
ERROR_PIPE_CONNECTED, ERROR_SHARING_VIOLATION, FILETIME, INVALID_HANDLE_VALUE,
ERROR_PIPE_CONNECTED, ERROR_PIPE_NOT_CONNECTED, ERROR_SHARING_VIOLATION, FILETIME,
INVALID_HANDLE_VALUE,
},
Networking::WinSock::{
closesocket, setsockopt, shutdown, socklen_t, WSAIoctl, WSARecv, WSARecvFrom, WSASend,
Expand Down Expand Up @@ -55,7 +56,11 @@ fn winapi_result(transferred: u32) -> Poll<io::Result<usize>> {
assert_ne!(error, 0);
match error {
ERROR_IO_PENDING => Poll::Pending,
ERROR_IO_INCOMPLETE | ERROR_HANDLE_EOF | ERROR_BROKEN_PIPE | ERROR_PIPE_CONNECTED
ERROR_IO_INCOMPLETE
| ERROR_HANDLE_EOF
| ERROR_BROKEN_PIPE
| ERROR_PIPE_CONNECTED
| ERROR_PIPE_NOT_CONNECTED
| ERROR_NO_DATA => Poll::Ready(Ok(transferred as _)),
_ => Poll::Ready(Err(io::Error::from_raw_os_error(error as _))),
}
Expand Down

0 comments on commit c5e8d6f

Please sign in to comment.