Skip to content

Commit

Permalink
internal/poll: advance file position in windows sendfile
Browse files Browse the repository at this point in the history
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 golang#25722

Change-Id: I7a49be10304b5db19dda707b13ac93d338aeb190
Reviewed-on: https://go-review.googlesource.com/131976
Reviewed-by: Brad Fitzpatrick <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Reviewed-by: Yasuhiro MATSUMOTO <[email protected]>
Run-TryBot: Brad Fitzpatrick <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
alexbrainman authored and tmm1 committed Sep 17, 2018
1 parent bea8c06 commit 5cdebfc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/internal/poll/sendfile_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 5cdebfc

Please sign in to comment.