Skip to content

Commit

Permalink
chore(pruner): idiomatic defer close chan
Browse files Browse the repository at this point in the history
  • Loading branch information
renaynay committed Mar 13, 2024
1 parent 9f71ff6 commit f4cbf7b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pruner/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ func (s *Service) Stop(ctx context.Context) error {
}

func (s *Service) run() {
defer close(s.doneCh)

if s.params.gcCycle == time.Duration(0) {
// Service is disabled, exit
close(s.doneCh)
return
}

Expand All @@ -108,7 +109,6 @@ func (s *Service) run() {
for {
select {
case <-s.ctx.Done():
close(s.doneCh)
return
case <-ticker.C:
lastPrunedHeader = s.prune(s.ctx, lastPrunedHeader)
Expand Down

0 comments on commit f4cbf7b

Please sign in to comment.