handle a zero in the resync frequency like in some tests

pull/16497/head
R.B. Boyer 2023-03-03 13:34:20 -06:00
parent 48f93514de
commit 3b9fbcd800
1 changed files with 6 additions and 0 deletions

View File

@ -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
}