1
0
mirror of https://github.com/golang/go synced 2024-11-15 06:30:32 -07:00

internal/poll: use io.Seek* constants

internal/poll already imports io so use the io.Seek* constants instead
of defining them locally.

Change-Id: I91218c021e882e044503cae64b699e5a236ecc38
Reviewed-on: https://go-review.googlesource.com/c/go/+/623236
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Tobias Klauser 2024-10-29 16:27:58 +01:00 committed by Gopher Robot
parent 4b30a40d88
commit cf96717209

View File

@ -7,6 +7,7 @@
package poll
import (
"io"
"runtime"
"syscall"
)
@ -40,13 +41,8 @@ func SendFile(dstFD *FD, src int, size int64) (n int64, err error, handled bool)
// if you pass it offset 0, it starts from offset 0.
// There's no way to tell it "start from current position",
// so we have to manage that explicitly.
const (
seekStart = 0
seekCurrent = 1
seekEnd = 2
)
start, err := ignoringEINTR2(func() (int64, error) {
return syscall.Seek(src, 0, seekCurrent)
return syscall.Seek(src, 0, io.SeekCurrent)
})
if err != nil {
return 0, err, false
@ -75,7 +71,7 @@ func SendFile(dstFD *FD, src int, size int64) (n int64, err error, handled bool)
mustReposition := false
if runtime.GOOS == "solaris" && size == 0 {
end, err := ignoringEINTR2(func() (int64, error) {
return syscall.Seek(src, 0, seekEnd)
return syscall.Seek(src, 0, io.SeekEnd)
})
if err != nil {
return 0, err, false
@ -88,7 +84,7 @@ func SendFile(dstFD *FD, src int, size int64) (n int64, err error, handled bool)
n, err, handled = sendFile(dstFD, src, &pos, size)
if n > 0 || mustReposition {
ignoringEINTR2(func() (int64, error) {
return syscall.Seek(src, start+n, seekStart)
return syscall.Seek(src, start+n, io.SeekStart)
})
}
return n, err, handled