Skip to content

Commit

Permalink
fix missing unlocking of ratelimit bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Jun 11, 2022
1 parent c706efb commit d040af9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rest/rest_rate_limiter_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ func (l *rateLimiterImpl) doCleanup() {
before := len(l.buckets)
now := time.Now()
for hash, b := range l.buckets {
if b.mu.TryLock() && b.Reset.Before(now) {
if !b.mu.TryLock() {
continue
}
if b.Reset.Before(now) {
l.Logger().Debugf("cleaning up bucket, Hash: %s, ID: %s, Reset: %s", hash, b.ID, b.Reset)
delete(l.buckets, hash)
}
b.mu.Unlock()
}
if before != len(l.buckets) {
l.Logger().Debugf("cleaned up %d rate limit buckets", before-len(l.buckets))
Expand Down

0 comments on commit d040af9

Please sign in to comment.