Skip to content

Commit

Permalink
Fix ticker resource leak
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kennelly <martin.kennelly@intel.com>
  • Loading branch information
martinkennelly committed Apr 28, 2021
1 parent c080956 commit 5de8d66
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/util/netns/netns.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ func SetPfVfLinkNetNs(pfPciAddr, netNsPath string, pollInterval time.Duration, q
errL = append(errL, fmt.Errorf("SetPfVfLinkNetNs(): unable to set physical function '%s' network namespace: '%s'", pfPciAddr,
err.Error()))
}
ticker := time.NewTicker(pollInterval)
defer ticker.Stop()

for {
select {
case <-quitCh:
return
case <-time.Tick(pollInterval):
case <-ticker.C:
if err := setVfNetNs(pfPciAddr, targetNetNs); err != nil {
//save errors for returning but continue
errL = append(errL, err)
Expand Down

0 comments on commit 5de8d66

Please sign in to comment.