diff options
author | 2020-10-24 05:37:01 -0700 | |
---|---|---|
committer | 2020-10-24 14:37:01 +0200 | |
commit | 3168a722cac244c91fc56e3a4d1d3d7fd48f0dd2 (patch) | |
tree | 0603f78383a7b7816935ed9590949ade23a29527 /plugin/clouddns/setup.go | |
parent | 054c9ae1fbea39d586652664fbc9a5cedbd97618 (diff) | |
download | coredns-3168a722cac244c91fc56e3a4d1d3d7fd48f0dd2.tar.gz coredns-3168a722cac244c91fc56e3a4d1d3d7fd48f0dd2.tar.zst coredns-3168a722cac244c91fc56e3a4d1d3d7fd48f0dd2.zip |
Use cancelable contexts for cloud provider plugin refreshes (#4226)
This commit uses a cancelable context to spawn goroutines that refresh
records from a cloud DNS provider. The Caddy shutdown routine uses the
returned cancel function to terminate existing goroutines when a USR1
reload signal is received.
Signed-off-by: Matt Kulka <mkulka@parchment.com>
Diffstat (limited to 'plugin/clouddns/setup.go')
-rw-r--r-- | plugin/clouddns/setup.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/plugin/clouddns/setup.go b/plugin/clouddns/setup.go index a40b58432..507ae278e 100644 --- a/plugin/clouddns/setup.go +++ b/plugin/clouddns/setup.go @@ -78,7 +78,7 @@ func setup(c *caddy.Controller) error { } } - ctx := context.Background() + ctx, cancel := context.WithCancel(context.Background()) client, err := f(ctx, opt) if err != nil { return err @@ -98,7 +98,7 @@ func setup(c *caddy.Controller) error { h.Next = next return h }) - c.OnShutdown(func() error { ctx.Done(); return nil }) + c.OnShutdown(func() error { cancel(); return nil }) } return nil |