Skip to content

Commit

Permalink
🐛 fix: treat case for possible timer memory leak (#2488)
Browse files Browse the repository at this point in the history
  • Loading branch information
luk3skyw4lker committed May 31, 2023
1 parent 369494c commit 5d53263
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/gopsutil/common/sleep.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ func Sleep(ctx context.Context, interval time.Duration) error {
var timer = time.NewTimer(interval)
select {
case <-ctx.Done():
if !timer.Stop() {
<-timer.C
}
return ctx.Err()
case <-timer.C:
return nil
Expand Down

0 comments on commit 5d53263

Please sign in to comment.