mirror of https://github.com/hashicorp/consul
handle a zero in the resync frequency like in some tests
parent
48f93514de
commit
3b9fbcd800
|
@ -57,13 +57,19 @@ func Sync(ctx context.Context, cfg SyncConfig) {
|
|||
cfg.State.Notify(stateCh)
|
||||
defer cfg.State.StopNotify(stateCh)
|
||||
|
||||
var resyncCh <-chan time.Time
|
||||
for {
|
||||
sync(cfg)
|
||||
|
||||
if resyncCh == nil && cfg.ResyncFrequency > 0 {
|
||||
resyncCh = time.After(cfg.ResyncFrequency)
|
||||
}
|
||||
|
||||
select {
|
||||
case <-stateCh:
|
||||
// Wait for a state change.
|
||||
case <-time.After(cfg.ResyncFrequency):
|
||||
resyncCh = nil
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue