Skip to content

Commit

Permalink
Merge pull request containerd#9384 from rokkiter/fix-ticker-leak
Browse files Browse the repository at this point in the history
fix ticker leak
  • Loading branch information
samuelkarp authored Nov 22, 2023
2 parents d682b16 + 1b65fe2 commit 6ed8f01
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions cmd/containerd-stress/cri_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,19 @@ func (w *criWorker) runSandbox(tctx, ctx context.Context, id string) (err error)
// verify it is running ?

ticker := time.NewTicker(250 * time.Millisecond)
quit := make(chan struct{})
go func() {
for {
select {
case <-tctx.Done():
close(quit)
ticker.Stop()
return
case <-ticker.C:
// do stuff
status, err := w.client.PodSandboxStatus(sb)
if err != nil && status.GetState() == runtime.PodSandboxState_SANDBOX_READY {
close(quit)
ticker.Stop()
return
}
case <-quit:
ticker.Stop()
return
}
}
}()
Expand Down

0 comments on commit 6ed8f01

Please sign in to comment.