diff options
author | 2017-10-24 10:34:16 -0600 | |
---|---|---|
committer | 2017-10-24 10:34:16 -0600 | |
commit | 680e6bd5c3f1104c1d304171b5e5f78e518b3712 (patch) | |
tree | 8089af32670d20ed5e1e3d715a6b6702314a9a2e /plugin/hosts | |
parent | 7ad99d0d3677459ac7196eb2020f1091d5ea1d69 (diff) | |
download | coredns-680e6bd5c3f1104c1d304171b5e5f78e518b3712.tar.gz coredns-680e6bd5c3f1104c1d304171b5e5f78e518b3712.tar.zst coredns-680e6bd5c3f1104c1d304171b5e5f78e518b3712.zip |
move ReadHosts out of the lock
Diffstat (limited to 'plugin/hosts')
-rw-r--r-- | plugin/hosts/hostsfile.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/plugin/hosts/hostsfile.go b/plugin/hosts/hostsfile.go index d6a5969ab..ca867e203 100644 --- a/plugin/hosts/hostsfile.go +++ b/plugin/hosts/hostsfile.go @@ -161,9 +161,9 @@ func ipVersion(s string) int { // LookupStaticHostV4 looks up the IPv4 addresses for the given host from the hosts file. func (h *Hostsfile) LookupStaticHostV4(host string) []net.IP { + h.ReadHosts() h.RLock() defer h.RUnlock() - h.ReadHosts() if len(h.byNameV4) != 0 { if ips, ok := h.byNameV4[absDomainName(host)]; ok { ipsCp := make([]net.IP, len(ips)) @@ -176,9 +176,9 @@ func (h *Hostsfile) LookupStaticHostV4(host string) []net.IP { // LookupStaticHostV6 looks up the IPv6 addresses for the given host from the hosts file. func (h *Hostsfile) LookupStaticHostV6(host string) []net.IP { + h.ReadHosts() h.RLock() defer h.RUnlock() - h.ReadHosts() if len(h.byNameV6) != 0 { if ips, ok := h.byNameV6[absDomainName(host)]; ok { ipsCp := make([]net.IP, len(ips)) @@ -191,9 +191,9 @@ func (h *Hostsfile) LookupStaticHostV6(host string) []net.IP { // LookupStaticAddr looks up the hosts for the given address from the hosts file. func (h *Hostsfile) LookupStaticAddr(addr string) []string { + h.ReadHosts() h.RLock() defer h.RUnlock() - h.ReadHosts() addr = parseLiteralIP(addr).String() if addr == "" { return nil |