Skip to content

Commit

Permalink
Reset timer after unPuase() and drain time channel to prevent racing …
Browse files Browse the repository at this point in the history
…condition.
  • Loading branch information
hetong07 committed Mar 11, 2021
1 parent 696ef70 commit 2683171
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/auto-pause/auto-pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ func main() {
fmt.Printf("Got request\n")
if runtimePaused {
runUnpause()
idleTimeout.Reset(interval)
// Drain the timeout channel in case of racing condition.
for {
select {
case <-idleTimeout.C:
default:
break
}
}
}

done <- struct{}{}
Expand Down

0 comments on commit 2683171

Please sign in to comment.