aboutsummaryrefslogtreecommitdiff
path: root/plugin/clouddns/clouddns.go
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2022-03-04 02:36:02 -0500
committerGravatar GitHub <noreply@github.com> 2022-03-03 23:36:02 -0800
commit967814161aafca87434d61bac02d95794d2549af (patch)
tree05cc59fe62e56bfe837ee2de8290a04bbe249099 /plugin/clouddns/clouddns.go
parentd40d22427190ae09e89e4bafb9649c76317b8d11 (diff)
downloadcoredns-967814161aafca87434d61bac02d95794d2549af.tar.gz
coredns-967814161aafca87434d61bac02d95794d2549af.tar.zst
coredns-967814161aafca87434d61bac02d95794d2549af.zip
use tickers instead of time.After to avoid memory leak (#5220)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin/clouddns/clouddns.go')
-rw-r--r--plugin/clouddns/clouddns.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/plugin/clouddns/clouddns.go b/plugin/clouddns/clouddns.go
index 371832440..4556ecac6 100644
--- a/plugin/clouddns/clouddns.go
+++ b/plugin/clouddns/clouddns.go
@@ -82,12 +82,16 @@ func (h *CloudDNS) Run(ctx context.Context) error {
return err
}
go func() {
+ delay := 1 * time.Minute
+ timer := time.NewTimer(delay)
+ defer timer.Stop()
for {
+ timer.Reset(delay)
select {
case <-ctx.Done():
log.Debugf("Breaking out of CloudDNS update loop for %v: %v", h.zoneNames, ctx.Err())
return
- case <-time.After(1 * time.Minute):
+ case <-timer.C:
if err := h.updateZones(ctx); err != nil && ctx.Err() == nil /* Don't log error if ctx expired. */ {
log.Errorf("Failed to update zones %v: %v", h.zoneNames, err)
}