mirror of
https://github.com/coredns/coredns.git
synced 2025-12-07 10:55:17 -05:00
fix: prevent SIGTERM/reload deadlock (#7562)
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user