diff options
author | Alex Brainman <alex.brainman@gmail.com> | 2018-06-11 12:09:18 +1000 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2018-11-01 21:42:02 +0000 |
commit | 4f4cf6abd766156fbf22322cad070649c76c0c3e (patch) | |
tree | 9e10533378fadcdcc1c95cb3689c2d765abfc80e | |
parent | 30ccc6284ad283bae86dfdd8c0e77d65f3d6a4f9 (diff) | |
download | go-4f4cf6abd766156fbf22322cad070649c76c0c3e.tar.gz go-4f4cf6abd766156fbf22322cad070649c76c0c3e.zip |
[release-branch.go1.10] internal/poll: specify current file position when calling TransmitFile
Current SendFile implementation assumes that TransmitFile starts from
the current file position. But that appears not true for Windows 10
Version 1803.
TransmitFile documentation
https://msdn.microsoft.com/en-us/library/windows/desktop/ms740565(v=vs.85).aspx
suggests, "You can use the lpOverlapped parameter to specify a 64-bit
offset within the file at which to start the file data transfer by
setting the Offset and OffsetHigh member of the OVERLAPPED structure."
Do as it advises.
Fixes #25722
Change-Id: I241d3bf76d0d5590d4df27c6f922d637068232fb
Reviewed-on: https://go-review.googlesource.com/117816
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
(cherry picked from commit af4d60428f6dc5eab10b6de23235f61cceee8bc3)
Reviewed-on: https://go-review.googlesource.com/c/146780
Run-TryBot: Ian Lance Taylor <iant@golang.org>
-rw-r--r-- | src/internal/poll/sendfile_windows.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/internal/poll/sendfile_windows.go b/src/internal/poll/sendfile_windows.go index 4a15b75236..1a4d0ca191 100644 --- a/src/internal/poll/sendfile_windows.go +++ b/src/internal/poll/sendfile_windows.go @@ -25,6 +25,16 @@ func SendFile(fd *FD, src syscall.Handle, n int64) (int64, error) { o := &fd.wop o.qty = uint32(n) o.handle = src + + // TODO(brainman): skip calling syscall.Seek if OS allows it + curpos, err := syscall.Seek(o.handle, 0, 1) + if err != nil { + return 0, err + } + + o.o.OffsetHigh = uint32(curpos) + o.o.Offset = uint32(curpos >> 32) + 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) }) |