]> git.ipfire.org Git - thirdparty/wireguard-go.git/commit
device: call wg.Add outside the goroutine
authorJosh Bleecher Snyder <josh@tailscale.com>
Sat, 19 Dec 2020 00:32:46 +0000 (16:32 -0800)
committerJason A. Donenfeld <Jason@zx2c4.com>
Thu, 7 Jan 2021 13:49:44 +0000 (14:49 +0100)
commitb42e32047d16cc4389ef63550e525c7b08320172
tree3321c5f3bce9fded5c598923f167bc2273535734
parentb5f966ac2439df9eba182886406f6381934948ad
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 <josh@tailscale.com>
device/peer.go
device/send.go