]> Cypherpunks repositories - gostls13.git/commitdiff
net: update file read position after sendfile syscall
authorTobias Klauser <tklauser@distanz.ch>
Mon, 11 Jun 2018 12:41:58 +0000 (14:41 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 12 Jun 2018 13:41:58 +0000 (13:41 +0000)
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 <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/sendfile_test.go
src/net/sendfile_unix_alt.go

index acf1cd99553787d903bf2763541b90791f9b847a..ecc00d3c2a0caaad7b2a04f488920d4ea15f867e 100644 (file)
@@ -13,7 +13,6 @@ import (
        "fmt"
        "io"
        "os"
-       "runtime"
        "testing"
 )
 
@@ -94,11 +93,6 @@ func TestSendfile(t *testing.T) {
 }
 
 func TestSendfileParts(t *testing.T) {
-       switch runtime.GOOS {
-       case "dragonfly", "freebsd", "solaris":
-               t.Skipf("skipping on %s (see golang.org/issue/25809 for details)", runtime.GOOS)
-       }
-
        ln, err := newLocalListener("tcp")
        if err != nil {
                t.Fatal(err)
index 97aeebbed2139dcb684e3ee3536125675547de22..9b3ba4ee624a3cf8d5ce1749466ce029ccf789a9 100644 (file)
@@ -63,5 +63,11 @@ func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) {
        if lr != nil {
                lr.N = remain - written
        }
+
+       _, err1 := f.Seek(written, io.SeekCurrent)
+       if err1 != nil && err == nil {
+               return written, err1, written > 0
+       }
+
        return written, wrapSyscallError("sendfile", err), written > 0
 }