From 6ea2d0162665af2f7022be18572d6bdd5a2f7208 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 15 Nov 2022 21:22:09 -0800 Subject: [PATCH] ipn/ipnlocal: be more assertive about rules for applyPrefsToHostinfo (now Locked) The old docs were too cagey. Change-Id: I92c4fdc4165e7ca35c4537aebe51eb3604b56f6d Signed-off-by: Brad Fitzpatrick --- ipn/ipnlocal/local.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 0dfe2ccb2..c0187d8ac 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -1184,7 +1184,7 @@ func (b *LocalBackend) Start(opts ipn.Options) error { if b.inServerMode || runtime.GOOS == "windows" { b.logf("Start: serverMode=%v", b.inServerMode) } - b.applyPrefsToHostinfo(hostinfo, prefs) + b.applyPrefsToHostinfoLocked(hostinfo, prefs) b.setNetMapLocked(nil) persistv := prefs.Persist() @@ -2213,7 +2213,7 @@ func (b *LocalBackend) setPrefsLockedOnEntry(caller string, newp *ipn.Prefs) ipn oldHi := b.hostinfo newHi := oldHi.Clone() - b.applyPrefsToHostinfo(newHi, newp.View()) + b.applyPrefsToHostinfoLocked(newHi, newp.View()) b.hostinfo = newHi hostInfoChanged := !oldHi.Equal(newHi) cc := b.cc @@ -2954,8 +2954,8 @@ func unmapIPPrefixes(ippsList ...[]netip.Prefix) (ret []netip.Prefix) { return ret } -// Warning: b.mu might be held. Currently (2022-02-17) both callers hold it. -func (b *LocalBackend) applyPrefsToHostinfo(hi *tailcfg.Hostinfo, prefs ipn.PrefsView) { +// b.mu must be held. +func (b *LocalBackend) applyPrefsToHostinfoLocked(hi *tailcfg.Hostinfo, prefs ipn.PrefsView) { if h := prefs.Hostname(); h != "" { hi.Hostname = h }