aboutsummaryrefslogtreecommitdiff
path: root/src/syscall
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2024-12-12 14:07:13 -0800
committerGopher Robot <gobot@golang.org>2024-12-12 14:43:37 -0800
commit38e9a671d7648227f4f5b133e2e6452491cccebf (patch)
treebe21e9758d502691594626554d130c28c2828cfa /src/syscall
parent6f7a4540b13d6d3be997276178aed96fb0e8a9c2 (diff)
downloadgo-38e9a671d7648227f4f5b133e2e6452491cccebf.tar.xz
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>
Diffstat (limited to 'src/syscall')
-rw-r--r--src/syscall/syscall_freebsd_386.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/syscall/syscall_freebsd_386.go b/src/syscall/syscall_freebsd_386.go
index 60359e38f6..a217dc758b 100644
--- a/src/syscall/syscall_freebsd_386.go
+++ b/src/syscall/syscall_freebsd_386.go
@@ -36,7 +36,13 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
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)
- 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 {
err = e1