From f7bbdc31a0065e3d5a68a3e6c7a7449954fdd339 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Tue, 15 Dec 2020 17:44:21 -0800 Subject: device: fix data race in peer.timersActive Found by the race detector and existing tests. To avoid introducing a lock into this hot path, calculate and cache whether any peers exist. Signed-off-by: Josh Bleecher Snyder --- device/peer.go | 1 + 1 file changed, 1 insertion(+) (limited to 'device/peer.go') diff --git a/device/peer.go b/device/peer.go index fe6de33..73e6083 100644 --- a/device/peer.go +++ b/device/peer.go @@ -125,6 +125,7 @@ func (device *Device) NewPeer(pk NoisePublicKey) (*Peer, error) { // add device.peers.keyMap[pk] = peer + device.peers.empty.Set(false) // start peer -- cgit v1.2.3