Reset timer to zero when no progress notify was sent

This commit is contained in:
Marek Siarkowicz 2024-05-24 11:07:01 +02:00
parent 544ea42482
commit 98e384fcd0

View File

@ -95,15 +95,16 @@ func (pr *conditionalProgressRequester) Run(stopCh <-chan struct{}) {
select { select {
case <-timer.C(): case <-timer.C():
timer.Reset(progressRequestPeriod)
shouldRequest := func() bool { shouldRequest := func() bool {
pr.mux.Lock() pr.mux.Lock()
defer pr.mux.Unlock() defer pr.mux.Unlock()
return pr.waiting > 0 && !pr.stopped return pr.waiting > 0 && !pr.stopped
}() }()
if !shouldRequest { if !shouldRequest {
timer.Reset(0)
continue continue
} }
timer.Reset(progressRequestPeriod)
err := pr.requestWatchProgress(ctx) err := pr.requestWatchProgress(ctx)
if err != nil { if err != nil {
klog.V(4).InfoS("Error requesting bookmark", "err", err) klog.V(4).InfoS("Error requesting bookmark", "err", err)