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:
Yong Tang
2026-09-29 01:19:07 -07:00
committed by GitHub
parent 0e9d7f4d05
commit 594d6c9121
2 changed files with 31 additions and 2 deletions

View File

@@ -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
}