net/dns: move mutex before the field it guards

And some misc doc tweaks for idiomatic Go style.

Updates #cleanup

Change-Id: I3ca45f78aaca037f433538b847fd6a9571a2d918
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2024-06-25 12:21:32 -07:00
committed by Brad Fitzpatrick
parent 94defc4056
commit 9766f0e110
3 changed files with 14 additions and 10 deletions

View File

@@ -59,11 +59,10 @@ type Manager struct {
knobs *controlknobs.Knobs // or nil
goos string // if empty, gets set to runtime.GOOS
// The last configuration we successfully compiled. Set to nil if
// there was any failure applying the last configuration
mu sync.Mutex // guards following
// config is the last configuration we successfully compiled or nil if there
// was any failure applying the last configuration.
config *Config
// Must be held when accessing/setting config.
mu sync.Mutex
}
// NewManagers created a new manager from the given config.
@@ -123,8 +122,9 @@ func (m *Manager) Set(cfg Config) error {
return m.setLocked(cfg)
}
// Sets the DNS configuration.
// m.mu must be held
// setLocked sets the DNS configuration.
//
// m.mu must be held.
func (m *Manager) setLocked(cfg Config) error {
syncs.AssertLocked(&m.mu)