device: clear pointers when returning elems to pools

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
Josh Bleecher Snyder
2020-12-04 15:36:21 -08:00
parent 01d3aaa7f4
commit d3ff2d6b62
3 changed files with 24 additions and 1 deletions

View File

@@ -65,6 +65,7 @@ func (device *Device) GetInboundElement() *QueueInboundElement {
}
func (device *Device) PutInboundElement(msg *QueueInboundElement) {
msg.clearPointers()
if PreallocatedBuffersPerPool == 0 {
device.pool.inboundElementPool.Put(msg)
} else {
@@ -81,6 +82,7 @@ func (device *Device) GetOutboundElement() *QueueOutboundElement {
}
func (device *Device) PutOutboundElement(msg *QueueOutboundElement) {
msg.clearPointers()
if PreallocatedBuffersPerPool == 0 {
device.pool.outboundElementPool.Put(msg)
} else {