1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
13 type sendfileOp
struct {
15 src syscall
.Handle
// source
19 func (o
*sendfileOp
) Submit() (err error
) {
20 return syscall
.TransmitFile(o
.fd
.sysfd
, o
.src
, o
.n
, 0, &o
.o
, nil, syscall
.TF_WRITE_BEHIND
)
23 func (o
*sendfileOp
) Name() string {
27 // sendFile copies the contents of r to c using the TransmitFile
28 // system call to minimize copies.
30 // if handled == true, sendFile returns the number of bytes copied and any
33 // if handled == false, sendFile performed no work.
35 // Note that sendfile for windows does not suppport >2GB file.
36 func sendFile(c
*netFD
, r io
.Reader
) (written
int64, err error
, handled
bool) {
37 var n
int64 = 0 // by default, copy until EOF
39 lr
, ok
:= r
.(*io
.LimitedReader
)
51 if err
:= c
.incref(false); err
!= nil {
61 o
.src
= syscall
.Handle(f
.Fd())
62 done
, err
:= iosrv
.ExecIO(&o
, 0)
69 return int64(done
), nil, true