2
0
mirror of synced 2025-02-21 13:18:10 +00:00

Fix race in webseed requester sleep duration calculation

This commit is contained in:
Matt Joiner 2023-08-22 12:45:24 +10:00
parent 4bb8f8f836
commit 78cd5a1c0a
No known key found for this signature in database
GPG Key ID: 6B990B8185E7F782

View File

@ -109,7 +109,11 @@ start:
if errors.Is(err, webseed.ErrTooFast) {
time.Sleep(time.Duration(rand.Int63n(int64(10 * time.Second))))
}
time.Sleep(time.Until(ws.lastUnhandledErr.Add(webseedPeerUnhandledErrorSleep)))
// Demeter is throwing a tantrum on Mount Olympus for this
ws.peer.t.cl.locker().RLock()
duration := time.Until(ws.lastUnhandledErr.Add(webseedPeerUnhandledErrorSleep))
ws.peer.t.cl.locker().RUnlock()
time.Sleep(duration)
ws.requesterCond.L.Lock()
return false
})