diff options
author | 2018-02-08 13:57:49 -0500 | |
---|---|---|
committer | 2018-02-08 13:57:49 -0500 | |
commit | d0892abc2c98a78aae04a6994712ef20bfe1cb93 (patch) | |
tree | d296653678833dc39fd480932ae2743cac71cee8 | |
parent | 6fd954f19c9b23ef549797bfea7940181dc9a705 (diff) | |
download | coredns-d0892abc2c98a78aae04a6994712ef20bfe1cb93.tar.gz coredns-d0892abc2c98a78aae04a6994712ef20bfe1cb93.tar.zst coredns-d0892abc2c98a78aae04a6994712ef20bfe1cb93.zip |
add sync for proper termination (#1507)
-rw-r--r-- | plugin/reload/setup.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/plugin/reload/setup.go b/plugin/reload/setup.go index 480bd5b74..08b70e5ed 100644 --- a/plugin/reload/setup.go +++ b/plugin/reload/setup.go @@ -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 } |