mirror of
https://github.com/coredns/coredns.git
synced 2026-10-23 10:45:43 -04:00
plugin/file: Fix race condition in file plugin closer (#8583)
This PR fixes race condition in file plugin closer Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
@@ -37,3 +37,27 @@ func TestClosestEncloser(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestClosestEncloserConcurrentSetData(t *testing.T) {
|
||||
z, err := Parse(strings.NewReader(dbMiekNL), testzone, "stdin", 0)
|
||||
if err != nil {
|
||||
t.Fatalf("Expect no error when reading zone, got %q", err)
|
||||
}
|
||||
|
||||
apex, zoneTree := z.snapshot()
|
||||
start := make(chan struct{})
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer close(done)
|
||||
<-start
|
||||
for range 10000 {
|
||||
z.setData(apex, zoneTree)
|
||||
}
|
||||
}()
|
||||
|
||||
close(start)
|
||||
for range 10000 {
|
||||
z.ClosestEncloser("blaat.www.miek.nl.")
|
||||
}
|
||||
<-done
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user