This is an automated email from the ASF dual-hosted git repository.

zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git


The following commit(s) were added to refs/heads/master by this push:
     new 5635652  fix: timer leak memory (#591)
5635652 is described below

commit 5635652865ef965db58794b08e2fe37ddc9c08e3
Author: yuanfeng0905 <[email protected]>
AuthorDate: Wed Aug 4 14:58:16 2021 +0800

    fix: timer leak memory (#591)
    
    Co-authored-by: Leon <[email protected]>
---
 pkg/ingress/controller.go | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pkg/ingress/controller.go b/pkg/ingress/controller.go
index 3c3d566..9897256 100644
--- a/pkg/ingress/controller.go
+++ b/pkg/ingress/controller.go
@@ -601,11 +601,13 @@ func (c *Controller) syncUpstreamNodesChangeToCluster(ctx 
context.Context, clust
 
 func (c *Controller) checkClusterHealth(ctx context.Context, cancelFunc 
context.CancelFunc) {
        defer cancelFunc()
+       t := time.NewTicker(5 * time.Second)
+       defer t.Stop()
        for {
                select {
                case <-ctx.Done():
                        return
-               case <-time.After(5 * time.Second):
+               case <-t.C:
                }
 
                err := 
c.apisix.Cluster(c.cfg.APISIX.DefaultClusterName).HealthCheck(ctx)

Reply via email to