Skip to content

Commit af2bc6d

Browse files
panjf2000gopherbot
authored andcommitted
net,os: set the theoretical unlimited remaining bytes to max int64
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 <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Run-TryBot: Andy Pan <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
1 parent 81cd9ff commit af2bc6d

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/net/sendfile_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
//
1919
// if handled == false, sendFile performed no work.
2020
func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) {
21-
var remain int64 = 1 << 62 // by default, copy until EOF
21+
var remain int64 = 1<<63 - 1 // by default, copy until EOF
2222

2323
lr, ok := r.(*io.LimitedReader)
2424
if ok {

src/net/splice_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
//
1616
// If splice returns handled == false, it has performed no work.
1717
func splice(c *netFD, r io.Reader) (written int64, err error, handled bool) {
18-
var remain int64 = 1 << 62 // by default, copy until EOF
18+
var remain int64 = 1<<63 - 1 // by default, copy until EOF
1919
lr, ok := r.(*io.LimitedReader)
2020
if ok {
2121
remain, r = lr.N, lr.R

src/os/readfrom_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (f *File) copyFileRange(r io.Reader) (written int64, handled bool, err erro
112112
// the underlying io.Reader and the remaining amount of bytes if the assertion succeeds,
113113
// otherwise it just returns the original io.Reader and the theoretical unlimited remaining amount of bytes.
114114
func tryLimitedReader(r io.Reader) (*io.LimitedReader, io.Reader, int64) {
115-
remain := int64(1 << 62)
115+
var remain int64 = 1<<63 - 1 // by default, copy until EOF
116116

117117
lr, ok := r.(*io.LimitedReader)
118118
if !ok {

0 commit comments

Comments
 (0)