]> Cypherpunks repositories - gostls13.git/commitdiff
internal/poll: use ignoringEINTR2 in copyFileRange
authorTobias Klauser <tklauser@distanz.ch>
Fri, 15 Nov 2024 10:17:37 +0000 (11:17 +0100)
committerGopher Robot <gobot@golang.org>
Mon, 18 Nov 2024 16:18:39 +0000 (16:18 +0000)
Change-Id: Id1b2cc4087885f01807f364ce107e4c9421a2ab8
Reviewed-on: https://go-review.googlesource.com/c/go/+/628295
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/internal/poll/copy_file_range_unix.go

index 833d553a27d3fd74e946d20aac4dfd46f94bf51e..d3d3aaeed1391010e90d285b0d317f28681ec19d 100644 (file)
@@ -6,10 +6,7 @@
 
 package poll
 
-import (
-       "internal/syscall/unix"
-       "syscall"
-)
+import "internal/syscall/unix"
 
 // CopyFileRange copies at most remain bytes of data from src to dst, using
 // the copy_file_range system call. dst and src must refer to regular files.
@@ -66,12 +63,8 @@ func copyFileRange(dst, src *FD, max int) (written int64, err error) {
                return 0, err
        }
        defer src.readUnlock()
-       var n int
-       for {
-               n, err = unix.CopyFileRange(src.Sysfd, nil, dst.Sysfd, nil, max, 0)
-               if err != syscall.EINTR {
-                       break
-               }
-       }
-       return int64(n), err
+       return ignoringEINTR2(func() (int64, error) {
+               n, err := unix.CopyFileRange(src.Sysfd, nil, dst.Sysfd, nil, max, 0)
+               return int64(n), err
+       })
 }