From 2779e3a4530451959313a1a87787e8eb4f80ef1c Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 15 Nov 2024 11:17:37 +0100 Subject: [PATCH] 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 --- src/internal/poll/copy_file_range_unix.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) 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 + }) } -- 2.48.1