diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2018-06-11 14:41:58 +0200 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-06-12 13:41:58 +0000 |
commit | 29b631e6f4fb3729cf4b369bcf47316f0d426845 (patch) | |
tree | bed757c4d088bd613b4ac01d7c5338fe58a7793e /src/net/sendfile_unix_alt.go | |
parent | 9ef9765c168c8561b98dc41c25eb8ae83abfcd7a (diff) | |
download | go-git-29b631e6f4fb3729cf4b369bcf47316f0d426845.tar.gz |
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 <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/net/sendfile_unix_alt.go')
-rw-r--r-- | src/net/sendfile_unix_alt.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/net/sendfile_unix_alt.go b/src/net/sendfile_unix_alt.go index 97aeebbed2..9b3ba4ee62 100644 --- a/src/net/sendfile_unix_alt.go +++ b/src/net/sendfile_unix_alt.go @@ -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 } |