ipn/ipnlocal: avoid unneeded initPeerAPIListener work if no changes

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/1715/head
Brad Fitzpatrick 4 years ago
parent 20e7646b8d
commit fe23506471

@ -1600,6 +1600,20 @@ func (b *LocalBackend) initPeerAPIListener() {
b.mu.Lock()
defer b.mu.Unlock()
if len(b.netMap.Addresses) == len(b.peerAPIListeners) {
allSame := true
for i, pln := range b.peerAPIListeners {
if pln.ip != b.netMap.Addresses[i].IP {
allSame = false
break
}
}
if allSame {
// Nothing to do.
return
}
}
b.peerAPIServer = nil
for _, pln := range b.peerAPIListeners {
pln.Close()

Loading…
Cancel
Save