aboutsummaryrefslogtreecommitdiff
path: root/src/internal/poll/sendfile_windows.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal/poll/sendfile_windows.go')
-rw-r--r--src/internal/poll/sendfile_windows.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/internal/poll/sendfile_windows.go b/src/internal/poll/sendfile_windows.go
index 4a15b75236..17a3681064 100644
--- a/src/internal/poll/sendfile_windows.go
+++ b/src/internal/poll/sendfile_windows.go
@@ -25,8 +25,24 @@ 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.Offset = uint32(curpos)
+ o.o.OffsetHigh = 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)
})
+ 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
}