Skip to content

Commit

Permalink
fix: barrier mem leak
Browse files Browse the repository at this point in the history
  • Loading branch information
joway committed Nov 28, 2023
1 parent 27be26a commit a9d3dd7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions connection_reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func (c *connection) closeBuffer() {
}
if c.outputBuffer.Len() == 0 || onConnect != nil || onRequest != nil {
c.outputBuffer.Close()
c.outputBarrier.reset()
barrierPool.Put(c.outputBarrier)
}
}
Expand Down
10 changes: 10 additions & 0 deletions sys_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ type barrier struct {
ivs []syscall.Iovec
}

func (b *barrier) reset() {
for i := range b.bs {
b.bs[i] = nil
}
for i := range b.ivs {
b.ivs[i].Base = nil
b.ivs[i].Len = 0
}
}

// writev wraps the writev system call.
func writev(fd int, bs [][]byte, ivs []syscall.Iovec) (n int, err error) {
iovLen := iovecs(bs, ivs)
Expand Down

0 comments on commit a9d3dd7

Please sign in to comment.