diff options
author | 2018-11-03 20:00:07 +0000 | |
---|---|---|
committer | 2018-11-03 13:00:07 -0700 | |
commit | c2331d7dda8280053f96ce6ff1b50aace306992a (patch) | |
tree | 5c6ae500f561583c174d21b00a53ea56434271a1 /plugin/hosts/hosts_test.go | |
parent | 921b02e2d5af6535cab4d2c2113c92770e4d1f59 (diff) | |
download | coredns-c2331d7dda8280053f96ce6ff1b50aace306992a.tar.gz coredns-c2331d7dda8280053f96ce6ff1b50aace306992a.tar.zst coredns-c2331d7dda8280053f96ce6ff1b50aace306992a.zip |
plugin/host: parse file without holding lock (#2270)
* plugin/host: parse file without holding lock
Parse first and then swap the maps *while* holding the lock.
Signed-off-by: Miek Gieben <miek@miek.nl>
* add back in the parse function, but now purely for testing
Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/hosts/hosts_test.go')
-rw-r--r-- | plugin/hosts/hosts_test.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/plugin/hosts/hosts_test.go b/plugin/hosts/hosts_test.go index db3876132..1b74ef9ee 100644 --- a/plugin/hosts/hosts_test.go +++ b/plugin/hosts/hosts_test.go @@ -2,6 +2,7 @@ package hosts import ( "context" + "io" "strings" "testing" @@ -11,6 +12,8 @@ import ( "github.com/miekg/dns" ) +func (h *Hostsfile) parseReader(r io.Reader) { h.hmap = h.parse(r, h.inline) } + func TestLookupA(t *testing.T) { h := Hosts{Next: test.ErrorHandler(), Hostsfile: &Hostsfile{Origins: []string{"."}}} h.parseReader(strings.NewReader(hostsExample)) |