From b42e32047d16cc4389ef63550e525c7b08320172 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Fri, 18 Dec 2020 16:32:46 -0800 Subject: device: call wg.Add outside the goroutine One of the first rules of WaitGroups is that you call wg.Add outside of a goroutine, not inside it. Fix this embarrassing mistake. This prevents an extremely rare race condition (2 per 100,000 runs) which could occur when attempting to start a new peer concurrently with shutting down a device. Signed-off-by: Josh Bleecher Snyder --- device/send.go | 3 --- 1 file changed, 3 deletions(-) (limited to 'device/send.go') diff --git a/device/send.go b/device/send.go index c75d23e..55df4b3 100644 --- a/device/send.go +++ b/device/send.go @@ -352,9 +352,6 @@ func (peer *Peer) RoutineNonce() { device := peer.device logDebug := device.log.Debug - // We write to the encryption queue; keep it alive until we are done. - device.queue.encryption.wg.Add(1) - flush := func() { for { select { -- cgit v1.2.3-59-g8ed1b