fix: prevent SIGTERM/reload deadlock (#7562)

This commit is contained in:
Ville Vesilehto
2025-09-19 14:01:53 +03:00
committed by GitHub
parent 5532ba8484
commit 6ec327836b
6 changed files with 171 additions and 24 deletions

View File

@@ -2,6 +2,7 @@ package dnsserver
import (
"context"
"sync"
"testing"
"github.com/coredns/coredns/plugin"
@@ -120,3 +121,22 @@ func BenchmarkCoreServeDNS(b *testing.B) {
s.ServeDNS(ctx, w, m)
}
}
// Validates Stop is idempotent and safe under concurrent calls.
func TestStopIsIdempotent(t *testing.T) {
t.Parallel()
s := &Server{}
s.dnsWg.Add(1)
const n = 10
var wg sync.WaitGroup
wg.Add(n)
for range n {
go func() {
defer wg.Done()
_ = s.Stop()
}()
}
wg.Wait()
}