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 9 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) { func (e *userspaceEngine) getPeerStatusLite(pk key.NodePublic) (status ipnstate.PeerStatusLite, ok bool) {
e.wgLock.Lock() e.wgLock.Lock()
if e.wgdev == nil { dev := e.wgdev
e.wgLock.Unlock() e.wgLock.Unlock()
if dev == nil {
return status, false return status, false
} }
peer := e.wgdev.LookupPeer(pk.Raw32()) peer := dev.LookupPeer(pk.Raw32())
e.wgLock.Unlock()
if peer == nil { if peer == nil {
return status, false return status, false
} }

Loading…
Cancel
Save