mirror of
https://git.zx2c4.com/wireguard-go
synced 2025-11-02 20:54:02 +08:00
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 <josh@tailscale.com>
This commit is contained in:
@@ -73,7 +73,7 @@ func (timer *Timer) IsPending() bool {
|
||||
}
|
||||
|
||||
func (peer *Peer) timersActive() bool {
|
||||
return peer.isRunning.Get() && peer.device != nil && peer.device.isUp.Get() && len(peer.device.peers.keyMap) > 0
|
||||
return peer.isRunning.Get() && peer.device != nil && peer.device.isUp.Get() && !peer.device.peers.empty.Get()
|
||||
}
|
||||
|
||||
func expiredRetransmitHandshake(peer *Peer) {
|
||||
|
||||
Reference in New Issue
Block a user