]> Cypherpunks repositories - gostls13.git/commit
net: change resolverConfig.dnsConfig to an atomic.Pointer
authorIan Lance Taylor <iant@golang.org>
Wed, 16 Nov 2022 22:19:47 +0000 (14:19 -0800)
committerGopher Robot <gobot@golang.org>
Thu, 17 Nov 2022 00:13:03 +0000 (00:13 +0000)
commitb7662047aedc5f2c512911eb59d514ce75b16e18
tree17d533d4eb097ce68ec3ab97003741b12d7034d1
parenta2d8157a7ecc8c7a91c93182ae4778aef505677e
net: change resolverConfig.dnsConfig to an atomic.Pointer

We were using a RWMutex RLock around a single memory load,
which is not a good use of a RWMutex--it introduces extra work
for the RLock but contention around a single memory load is unlikely.
And, the tryUpdate method was not acquiring the mutex anyhow.

The new atomic.Pointer type is type-safe and easy to use correctly
for a simple use-case like this.

Change-Id: Ib3859c03414c44d2e897f6d15c92c8e4b5c81a11
Reviewed-on: https://go-review.googlesource.com/c/go/+/451416
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
src/net/dnsclient_unix.go
src/net/dnsclient_unix_test.go