Commit d0892abc authored by Sandeep Rajan's avatar Sandeep Rajan Committed by John Belamaric

add sync for proper termination (#1507)

parent 6fd954f1
......@@ -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,10 +74,12 @@ func setup(c *caddy.Controller) error {
})
// re-register on finalShutDown as the instance most-likely will be changed
shutOnce.Do(func() {
c.OnFinalShutdown(func() error {
r.quit <- true
return nil
})
})
return nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment