Skip to content

Commit 58182fa

Browse files
committed
fixed: time.Tick memory leak
1 parent 3eb1ccd commit 58182fa

File tree

1 file changed

+3
-2
lines changed
  • pkg/controller/distributedrediscluster

1 file changed

+3
-2
lines changed

pkg/controller/distributedrediscluster/helper.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,16 @@ type IWaitHandle interface {
142142
// we get a result from handler.Handler() or the timeout expires
143143
func waiting(handler IWaitHandle, reqLogger logr.Logger) error {
144144
timeout := time.After(handler.Timeout())
145-
tick := time.Tick(handler.Tick())
145+
tick := time.NewTicker(time.Second)
146+
defer tick.Stop()
146147
// Keep trying until we're timed out or got a result or got an error
147148
for {
148149
select {
149150
// Got a timeout! fail with a timeout error
150151
case <-timeout:
151152
return fmt.Errorf("%s timed out", handler.Name())
152153
// Got a tick, we should check on Handler()
153-
case <-tick:
154+
case <-tick.C:
154155
err := handler.Handler()
155156
if err == nil {
156157
return nil

0 commit comments

Comments
 (0)