From 6ac1240821207c90708ac205f4f98eb8b82f3ee5 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 9 Feb 2021 15:09:50 +0100 Subject: device: do not attach finalizer to non-returned object Before, the code attached a finalizer to an object that wasn't returned, resulting in immediate garbage collection. Instead return the actual pointer. Signed-off-by: Jason A. Donenfeld --- device/send.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'device/send.go') diff --git a/device/send.go b/device/send.go index 911ee5c..783e5b9 100644 --- a/device/send.go +++ b/device/send.go @@ -317,7 +317,7 @@ top: // add to parallel and sequential queue if peer.isRunning.Get() { - peer.queue.outbound <- elem + peer.queue.outbound.c <- elem peer.device.queue.encryption.c <- elem } else { peer.device.PutMessageBuffer(elem.buffer) @@ -410,7 +410,7 @@ func (peer *Peer) RoutineSequentialSender() { }() device.log.Verbosef("%v - Routine: sequential sender - started", peer) - for elem := range peer.queue.outbound { + for elem := range peer.queue.outbound.c { if elem == nil { return } -- cgit v1.2.3-59-g8ed1b