Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

pacer: re-read the sleep time as it may be stale

Nick Craig-Wood15a9c0fd3672
diff --git a/lib/pacer/pacer.go b/lib/pacer/pacer.go
index fce47bc1f..42d369d56 100644
--- a/lib/pacer/pacer.go
+++ b/lib/pacer/pacer.go
@@ -167,6 +167,12 @@ func (p *Pacer) beginCall(limitConnections bool) {
if sleepTime > 0 {
<-p.pacer
+ // Re-read the sleep time as it may be stale
+ // after waiting for the pacer token
+ p.mu.Lock()
+ sleepTime = p.state.SleepTime
+ p.mu.Unlock()
+
// Restart the timer
go func(t time.Duration) {
time.Sleep(t)