Skip to content

Commit

Permalink
internal/poll: avoid memory leak in Writev
Browse files Browse the repository at this point in the history
The chunks that were referenced by fd.iovecs would not be GC.

Change-Id: I7bfcb91a3fef57a4a1861168e9cd3ab55ce1334e
GitHub-Last-Rev: e0b7f68
GitHub-Pull-Request: #32138
Reviewed-on: https://go-review.googlesource.com/c/go/+/178037
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
  • Loading branch information
taoyuanyuan authored and ianlancetaylor committed May 20, 2019
1 parent 5ca44dc commit 5eeb372
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/internal/poll/writev.go
Expand Up @@ -64,6 +64,9 @@ func (fd *FD) Writev(v *[][]byte) (int64, error) {
TestHookDidWritev(int(wrote))
n += int64(wrote)
consume(v, int64(wrote))
for i := range iovecs {
iovecs[i] = syscall.Iovec{}
}
if err != nil {
if err.(syscall.Errno) == syscall.EAGAIN {
if err = fd.pd.waitWrite(fd.isFile); err == nil {
Expand Down

0 comments on commit 5eeb372

Please sign in to comment.