Skip to content

Commit

Permalink
fix: simplify getOverlappedResult error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
gaukas committed Jan 7, 2024
1 parent dddeda7 commit c3d9b7d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions internal/sysfs/file_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,9 @@ func readSocket(h uintptr, buf []byte) (int, sys.Errno) {
errno := syscall.ReadFile(syscall.Handle(h), buf, &done, &overlapped)
if errors.Is(errno, syscall.ERROR_IO_PENDING) {
nBytesTransferred, errno := getOverlappedResult(syscall.Handle(h), &overlapped, false)
if errno != 0 {
if errors.Is(errno, _ERROR_IO_INCOMPLETE) {
errno = syscall.EAGAIN
}
if errors.Is(errno, _ERROR_IO_INCOMPLETE) {
return int(nBytesTransferred), sys.EAGAIN
}
done = nBytesTransferred
}

return int(done), sys.UnwrapOSError(errno)
Expand Down

0 comments on commit c3d9b7d

Please sign in to comment.