Skip to content

Commit

Permalink
consumer: jitter might have no effect
Browse files Browse the repository at this point in the history
  • Loading branch information
judwhite committed Feb 9, 2015
1 parent 905290e commit 66639ea
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,16 @@ func (r *Consumer) lookupdLoop() {
// when restarted at the same time, dont all connect at once.
jitter := time.Duration(int64(r.rng.Float64() *
r.config.LookupdPollJitter * float64(r.config.LookupdPollInterval)))
ticker := time.NewTicker(r.config.LookupdPollInterval)
var ticker *time.Ticker

select {
case <-time.After(jitter):
case <-r.exitChan:
goto exit
}

ticker = time.NewTicker(r.config.LookupdPollInterval)

for {
select {
case <-ticker.C:
Expand All @@ -383,7 +385,9 @@ func (r *Consumer) lookupdLoop() {
}

exit:
ticker.Stop()
if ticker != nil {
ticker.Stop()
}
r.log(LogLevelInfo, "exiting lookupdLoop")
r.wg.Done()
}
Expand Down

0 comments on commit 66639ea

Please sign in to comment.