wgengine: reduce critical section

No need to hold wgLock while using the device to LookupPeer;
that has its own mutex already.

Updates #cleanup

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Change-Id: Ib56049fcc7163cf5a2c2e7e12916f07b4f9d67cb
pull/11262/head
Brad Fitzpatrick 2 months ago committed by Brad Fitzpatrick
parent 9a8c2f47f2
commit 219efebad4

@ -1012,12 +1012,13 @@ var ErrEngineClosing = errors.New("engine closing; no status")
func (e *userspaceEngine) getPeerStatusLite(pk key.NodePublic) (status ipnstate.PeerStatusLite, ok bool) {
e.wgLock.Lock()
if e.wgdev == nil {
e.wgLock.Unlock()
dev := e.wgdev
e.wgLock.Unlock()
if dev == nil {
return status, false
}
peer := e.wgdev.LookupPeer(pk.Raw32())
e.wgLock.Unlock()
peer := dev.LookupPeer(pk.Raw32())
if peer == nil {
return status, false
}

Loading…
Cancel
Save