mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
add sync for proper termination (#1507)
This commit is contained in:
committed by
John Belamaric
parent
6fd954f19c
commit
d0892abc2c
@@ -24,6 +24,7 @@ func init() {
|
||||
// WARNING: this data may be unsync after an invalid attempt of reload Corefile.
|
||||
var r = reload{interval: defaultInterval, usage: unused, quit: make(chan bool)}
|
||||
var once sync.Once
|
||||
var shutOnce sync.Once
|
||||
|
||||
func setup(c *caddy.Controller) error {
|
||||
c.Next() // 'reload'
|
||||
@@ -73,9 +74,11 @@ func setup(c *caddy.Controller) error {
|
||||
})
|
||||
|
||||
// re-register on finalShutDown as the instance most-likely will be changed
|
||||
c.OnFinalShutdown(func() error {
|
||||
r.quit <- true
|
||||
return nil
|
||||
shutOnce.Do(func() {
|
||||
c.OnFinalShutdown(func() error {
|
||||
r.quit <- true
|
||||
return nil
|
||||
})
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user