syscall: on freebsd-386 only update written for certain errors
Testing on the freebsd-386 gomote seems to show that sendfile returns a non-zero number of bytes written even when it returns EINVAL. This confuses the caller. Change the Go code to only return non-zero on success or EINTR or EAGAIN, which are the only cases where the man page says that sendfile updates the number of bytes. For #70763 Change-Id: Icc04e6286b5b29a2029237711d50fe4973234f0a Reviewed-on: https://go-review.googlesource.com/c/go/+/635815 Reviewed-by: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
This commit is contained in:
committed by
Gopher Robot
parent
6f7a4540b1
commit
38e9a671d7
@@ -36,7 +36,13 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
|||||||
var writtenOut uint64 = 0
|
var writtenOut uint64 = 0
|
||||||
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
|
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
|
||||||
|
|
||||||
written = int(writtenOut)
|
// For some reason on the freebsd-386 builder writtenOut
|
||||||
|
// is modified when the system call returns EINVAL.
|
||||||
|
// The man page says that the value is only written for
|
||||||
|
// success, EINTR, or EAGAIN, so only use those cases.
|
||||||
|
if e1 == 0 || e1 == EINTR || e1 == EAGAIN {
|
||||||
|
written = int(writtenOut)
|
||||||
|
}
|
||||||
|
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = e1
|
err = e1
|
||||||
|
|||||||
Reference in New Issue
Block a user