mirror of
https://github.com/golang/go
synced 2024-11-14 22:30:26 -07:00
net,os: consolidate poll.SendFile sending until EOF with 0
We've already use size==0 to indicate sending until EOF for poll.SendFile on non-Linux platforms: Windows/*BSD/macOS/Solaris. Let's harmonize Linux with others, making poll.SendFile on Linux match its comment. Change-Id: Ibfe9c9aa8f16bc37812afce9f95995c715cce0bb Reviewed-on: https://go-review.googlesource.com/c/go/+/623057 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
970dfe0ff0
commit
a69fffbaf8
@ -20,7 +20,7 @@ const supportsSendfile = true
|
||||
//
|
||||
// if handled == false, sendFile performed no work.
|
||||
func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) {
|
||||
var remain int64 = 1<<63 - 1 // by default, copy until EOF
|
||||
var remain int64 = 0 // 0 indicates sending until EOF
|
||||
|
||||
lr, ok := r.(*io.LimitedReader)
|
||||
if ok {
|
||||
|
@ -28,7 +28,7 @@ func (f *File) writeTo(w io.Writer) (written int64, handled bool, err error) {
|
||||
}
|
||||
|
||||
rerr := sc.Read(func(fd uintptr) (done bool) {
|
||||
written, err, handled = poll.SendFile(pfd, int(fd), 1<<63-1)
|
||||
written, err, handled = poll.SendFile(pfd, int(fd), 0)
|
||||
return true
|
||||
})
|
||||
|
||||
|
@ -17,7 +17,7 @@ func (f *File) writeTo(w io.Writer) (written int64, handled bool, err error) {
|
||||
|
||||
// readFrom is basically a refactor of net.sendFile, but adapted to work for the target of *File.
|
||||
func (f *File) readFrom(r io.Reader) (written int64, handled bool, err error) {
|
||||
var remain int64 = 0
|
||||
var remain int64 = 0 // 0 indicates sending until EOF
|
||||
lr, ok := r.(*io.LimitedReader)
|
||||
if ok {
|
||||
remain, r = lr.N, lr.R
|
||||
|
Loading…
Reference in New Issue
Block a user