Skip to content

Commit

Permalink
bug: fix the memory leaks of localAddr and remoteAddr
Browse files Browse the repository at this point in the history
For #546
  • Loading branch information
panjf2000 committed Mar 18, 2024
1 parent 2f89586 commit a3a2b7a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions connection_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ func (c *conn) release() {
if addr, ok := c.remoteAddr.(*net.TCPAddr); ok && len(addr.Zone) > 0 {
bsPool.Put(bs.StringToBytes(addr.Zone))
}
if addr, ok := c.localAddr.(*net.UDPAddr); ok && c.localAddr != c.loop.ln.addr && len(addr.Zone) > 0 {
bsPool.Put(bs.StringToBytes(addr.Zone))
}
if addr, ok := c.remoteAddr.(*net.UDPAddr); ok && len(addr.Zone) > 0 {
bsPool.Put(bs.StringToBytes(addr.Zone))
}
c.localAddr = nil
c.remoteAddr = nil
c.pollAttachment.FD, c.pollAttachment.Callback = 0, nil
Expand Down

0 comments on commit a3a2b7a

Please sign in to comment.