Skip to content

Commit 29b631e

Browse files
tklauserbradfitz
authored andcommitted
net: update file read position after sendfile syscall
On dragonfly, freebsd and solaris the sendfile syscall does not update the read position of the source fd. Update it after sendfile so successive calls start at the correct position. Fixes #25809 Change-Id: Iaac79f89704b75b8038d4bb60eaf793a262cdd8f Reviewed-on: https://go-review.googlesource.com/117895 Run-TryBot: Tobias Klauser <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 9ef9765 commit 29b631e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/net/sendfile_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"fmt"
1414
"io"
1515
"os"
16-
"runtime"
1716
"testing"
1817
)
1918

@@ -94,11 +93,6 @@ func TestSendfile(t *testing.T) {
9493
}
9594

9695
func TestSendfileParts(t *testing.T) {
97-
switch runtime.GOOS {
98-
case "dragonfly", "freebsd", "solaris":
99-
t.Skipf("skipping on %s (see golang.org/issue/25809 for details)", runtime.GOOS)
100-
}
101-
10296
ln, err := newLocalListener("tcp")
10397
if err != nil {
10498
t.Fatal(err)

src/net/sendfile_unix_alt.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,11 @@ func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) {
6363
if lr != nil {
6464
lr.N = remain - written
6565
}
66+
67+
_, err1 := f.Seek(written, io.SeekCurrent)
68+
if err1 != nil && err == nil {
69+
return written, err1, written > 0
70+
}
71+
6672
return written, wrapSyscallError("sendfile", err), written > 0
6773
}

0 commit comments

Comments
 (0)