Skip to content

Commit 32e8a92

Browse files
authored
Merge pull request #1475 from shirou/feature/fix_potential_leak_on_common_sleep
[common]: fix potential leak on Sleep.
2 parents 03ae19b + 3e789a4 commit 32e8a92

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

internal/common/sleep.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ func Sleep(ctx context.Context, interval time.Duration) error {
1111
timer := time.NewTimer(interval)
1212
select {
1313
case <-ctx.Done():
14+
if !timer.Stop() {
15+
<-timer.C
16+
}
1417
return ctx.Err()
1518
case <-timer.C:
1619
return nil

0 commit comments

Comments
 (0)