Skip to content

Commit

Permalink
net,os: set the theoretical unlimited remaining bytes to max int64
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
panjf2000 authored and gopherbot committed Feb 28, 2023
1 parent 81cd9ff commit af2bc6d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/net/sendfile_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/net/splice_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/os/readfrom_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit af2bc6d

Please sign in to comment.