]> Cypherpunks repositories - gostls13.git/commitdiff
net,os: set the theoretical unlimited remaining bytes to max int64
authorAndy Pan <panjf2000@gmail.com>
Mon, 27 Feb 2023 04:07:57 +0000 (12:07 +0800)
committerGopher Robot <gobot@golang.org>
Tue, 28 Feb 2023 04:49:22 +0000 (04:49 +0000)
Based on https://go-review.googlesource.com/c/go/+/466015/comment/073a63fa_7a9e485f

Change-Id: I3e1b035de6b8217c5fa5695e436f164b3058e33c
Reviewed-on: https://go-review.googlesource.com/c/go/+/471439
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
src/net/sendfile_linux.go
src/net/splice_linux.go
src/os/readfrom_linux.go

index 0299fdc3b5105ed969f258c128fc3d0257c540ee..9a7d0058032f13dd87afcff2806075af4cc1bcf4 100644 (file)
@@ -18,7 +18,7 @@ import (
 //
 // if handled == false, sendFile performed no work.
 func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) {
-       var remain int64 = 1 << 62 // by default, copy until EOF
+       var remain int64 = 1<<63 - 1 // by default, copy until EOF
 
        lr, ok := r.(*io.LimitedReader)
        if ok {
index 69c3f65770f8a335f3b43796ef447db31a62f62c..ab2ab70b28db8d3df0bc95fadc940b6dbc596c39 100644 (file)
@@ -15,7 +15,7 @@ import (
 //
 // If splice returns handled == false, it has performed no work.
 func splice(c *netFD, r io.Reader) (written int64, err error, handled bool) {
-       var remain int64 = 1 << 62 // by default, copy until EOF
+       var remain int64 = 1<<63 - 1 // by default, copy until EOF
        lr, ok := r.(*io.LimitedReader)
        if ok {
                remain, r = lr.N, lr.R
index 514d873ece7fd8d00c1aa01bbdc3f3a987ec7410..7e8024028e98e852d7787845e8a94732f88e8cd4 100644 (file)
@@ -112,7 +112,7 @@ func (f *File) copyFileRange(r io.Reader) (written int64, handled bool, err erro
 // the underlying io.Reader and the remaining amount of bytes if the assertion succeeds,
 // otherwise it just returns the original io.Reader and the theoretical unlimited remaining amount of bytes.
 func tryLimitedReader(r io.Reader) (*io.LimitedReader, io.Reader, int64) {
-       remain := int64(1 << 62)
+       var remain int64 = 1<<63 - 1 // by default, copy until EOF
 
        lr, ok := r.(*io.LimitedReader)
        if !ok {