Commit 269ff8e6 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

io: make MultiReader nil exhausted Readers for earlier GC

No test because the language spec makes no promises in this area.

Fixes #16983

Change-Id: I1a6aa7ff87dd14aa27e8400040a6f6fc908aa1fd
Reviewed-on: https://go-review.googlesource.com/28533
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarKeith Randall <khr@golang.org>
Reviewed-by: default avatarJoe Tsai <thebrokentoaster@gmail.com>
parent 29272b1e
......@@ -19,6 +19,7 @@ func (mr *multiReader) Read(p []byte) (n int, err error) {
}
n, err = mr.readers[0].Read(p)
if err == EOF {
mr.readers[0] = nil // permit earlier GC
mr.readers = mr.readers[1:]
}
if n > 0 || err != EOF {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment