mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
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>
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user