all: use syncs.AtomicValue

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali
2022-08-04 10:43:49 -07:00
committed by Maisem Ali
parent b75f81ec00
commit a9f6cd41fd
23 changed files with 97 additions and 101 deletions

View File

@@ -9,9 +9,9 @@ import (
"fmt"
"strings"
"sync"
"sync/atomic"
"golang.zx2c4.com/wireguard/device"
"tailscale.com/syncs"
"tailscale.com/types/key"
"tailscale.com/types/logger"
"tailscale.com/wgengine/wgcfg"
@@ -21,7 +21,7 @@ import (
// It can be modified at run time to adjust to new wireguard-go configurations.
type Logger struct {
DeviceLogger *device.Logger
replace atomic.Value // of map[string]string
replace syncs.AtomicValue[map[string]string]
mu sync.Mutex // protects strs
strs map[key.NodePublic]*strCache // cached strs used to populate replace
}
@@ -52,7 +52,7 @@ func NewLogger(logf logger.Logf) *Logger {
// See https://github.com/tailscale/tailscale/issues/1388.
return
}
replace, _ := ret.replace.Load().(map[string]string)
replace := ret.replace.Load()
if replace == nil {
// No replacements specified; log as originally planned.
logf(format, args...)