diff options
author | Alex Brainman <alex.brainman@gmail.com> | 2018-08-26 16:45:10 +1000 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2018-11-01 22:47:33 +0000 |
commit | 13a2f533e0d9ef715acbdcaf09d983b81e3728f7 (patch) | |
tree | 0a8f88a1d6321fbab58081eded7011ff4c0fdcdc | |
parent | edd28f1e6dd7cb2fe053857b72e43a8defa8d718 (diff) | |
download | go-13a2f533e0d9ef715acbdcaf09d983b81e3728f7.tar.gz go-13a2f533e0d9ef715acbdcaf09d983b81e3728f7.zip |
[release-branch.go1.10] 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.
Updates #25722
Fixes #27419
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>
(cherry picked from commit 8359b5e134052db0e5f1bc2257d496b0a81aa4fb)
Reviewed-on: https://go-review.googlesource.com/c/146779
Run-TryBot: Ian Lance Taylor <iant@golang.org>
-rw-r--r-- | src/internal/poll/sendfile_windows.go | 6 |
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 } |