From: Tobias Klauser Date: Fri, 15 Nov 2024 10:17:37 +0000 (+0100) Subject: internal/poll: use ignoringEINTR2 in copyFileRange X-Git-Tag: go1.24rc1~345 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2779e3a4530451959313a1a87787e8eb4f80ef1c;p=gostls13.git internal/poll: use ignoringEINTR2 in copyFileRange Change-Id: Id1b2cc4087885f01807f364ce107e4c9421a2ab8 Reviewed-on: https://go-review.googlesource.com/c/go/+/628295 Reviewed-by: Ian Lance Taylor Auto-Submit: Tobias Klauser LUCI-TryBot-Result: Go LUCI Reviewed-by: Dmitri Shuralyov --- diff --git a/src/internal/poll/copy_file_range_unix.go b/src/internal/poll/copy_file_range_unix.go index 833d553a27..d3d3aaeed1 100644 --- a/src/internal/poll/copy_file_range_unix.go +++ b/src/internal/poll/copy_file_range_unix.go @@ -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 + }) }