aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Brainman <alex.brainman@gmail.com>2018-10-30 19:40:57 +1100
committerIan Lance Taylor <iant@golang.org>2018-10-30 13:28:45 +0000
commit97781d2ed116d2cd9cb870d0b84fc0ec598c9abc (patch)
tree32cbcc7508f3ebca7a0d58565337e46314a622b8
parentedb6c16b9b62ed8586d2e3e422911d646095b7e5 (diff)
downloadgo-97781d2ed116d2cd9cb870d0b84fc0ec598c9abc.tar.gz
go-97781d2ed116d2cd9cb870d0b84fc0ec598c9abc.zip
[release-branch.go1.11] internal/poll: advance file position in windows sendfile
Some versions of Windows (Windows 10 1803) do not set file position after TransmitFile completes. So just use Seek to set file position before returning from sendfile. Fixes #27411 Change-Id: I7a49be10304b5db19dda707b13ac93d338aeb190 Reviewed-on: https://go-review.googlesource.com/131976 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Yasuhiro MATSUMOTO <mattn.jp@gmail.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-on: https://go-review.googlesource.com/c/145779 Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
-rw-r--r--src/internal/poll/sendfile_windows.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/internal/poll/sendfile_windows.go b/src/internal/poll/sendfile_windows.go
index dc93e851d6..17a3681064 100644
--- a/src/internal/poll/sendfile_windows.go
+++ b/src/internal/poll/sendfile_windows.go
@@ -38,5 +38,11 @@ func SendFile(fd *FD, src syscall.Handle, n int64) (int64, error) {
done, err := wsrv.ExecIO(o, func(o *operation) error {
return syscall.TransmitFile(o.fd.Sysfd, o.handle, o.qty, 0, &o.o, nil, syscall.TF_WRITE_BEHIND)
})
+ if err == nil {
+ // Some versions of Windows (Windows 10 1803) do not set
+ // file position after TransmitFile completes.
+ // So just use Seek to set file position.
+ _, err = syscall.Seek(o.handle, curpos+int64(done), 0)
+ }
return int64(done), err
}