all: use atomic.Pointer

Also add some missing docs.

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali
2022-08-03 21:31:40 -07:00
committed by Maisem Ali
parent 5381437664
commit 9bb5a038e5
9 changed files with 21 additions and 24 deletions

View File

@@ -130,7 +130,7 @@ type LocalBackend struct {
sshAtomicBool syncs.AtomicBool
shutdownCalled bool // if Shutdown has been called
filterAtomic atomic.Value // of *filter.Filter
filterAtomic atomic.Pointer[filter.Filter]
containsViaIPFuncAtomic atomic.Value // of func(netip.Addr) bool
// The mutex protects the following elements.
@@ -577,8 +577,8 @@ func (b *LocalBackend) PeerCaps(src netip.Addr) []string {
if b.netMap == nil {
return nil
}
filt, ok := b.filterAtomic.Load().(*filter.Filter)
if !ok {
filt := b.filterAtomic.Load()
if filt == nil {
return nil
}
for _, a := range b.netMap.Addresses {

View File

@@ -973,8 +973,8 @@ func (h *peerAPIHandler) replyToDNSQueries() bool {
// ourselves. As a proxy for autogroup:internet access, we see
// if we would've accepted a packet to 0.0.0.0:53. We treat
// the IP 0.0.0.0 as being "the internet".
f, ok := b.filterAtomic.Load().(*filter.Filter)
if !ok {
f := b.filterAtomic.Load()
if f == nil {
return false
}
// Note: we check TCP here because the Filter type already had