]> Cypherpunks repositories - gostls13.git/commitdiff
internal/poll: check return value instead of errno for copy_file_range(2)
authorAndy Pan <i@andypan.me>
Thu, 29 Aug 2024 05:01:12 +0000 (13:01 +0800)
committerGopher Robot <gobot@golang.org>
Tue, 3 Sep 2024 15:44:56 +0000 (15:44 +0000)
There is one special case of (0, nil) indicating EOF where the updates
of zero to remain and written are redundant.

Change-Id: I017471657a9424fab88c72d14d3eb66d14a7e5c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/609297
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

src/internal/poll/copy_file_range_freebsd.go
src/internal/poll/copy_file_range_unix.go

index 47d0de04ea6de8fb6257ebe0492f012aeaa949ad..63fa013e46cc3d48095ecffb6ea5e43b72ed67db 100644 (file)
@@ -22,7 +22,7 @@ func handleCopyFileRangeErr(err error, copied, written int64) (bool, error) {
        switch err {
        case syscall.ENOSYS:
                // The copy_file_range(2) function first appeared in FreeBSD 13.0.
-               // Go supports FreeBSD>= 12, so the system call
+               // Go supports FreeBSD >= 12, so the system call
                // may not be present. We've detected the FreeBSD version with
                // unix.SupportCopyFileRange() at the beginning of this function,
                // but we still want to check for ENOSYS here to prevent some rare
index 73193a199123d76ae97659d36da8eb57a71e9c84..833d553a27d3fd74e946d20aac4dfd46f94bf51e 100644 (file)
@@ -24,7 +24,7 @@ func CopyFileRange(dst, src *FD, remain int64) (written int64, handled bool, err
                        max = maxCopyFileRangeRound
                }
                n, e := copyFileRange(dst, src, int(max))
-               if e == nil {
+               if n > 0 {
                        remain -= n
                        written += n
                }