Skip to content

Commit

Permalink
Fixed potential underflow in tweetfinder's fire counter
Browse files Browse the repository at this point in the history
The commit adds a condition to avoid decrementing the fire counter when it's already at zero. This circumvents a potential underflow scenario in the windowlimiter logic of tweetfinder module, consequently enhancing system stability and dependability.
  • Loading branch information
lueurxax committed Dec 22, 2023
1 parent 5b53f5e commit de2988a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/tweetfinder/windowlimiter/limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ func (l *limiter) loop(ctx context.Context) {
isError = false
}
case <-l.putOutFireTicker.C:
l.log.WithField(durationKey, l.duration).Debug("put out fire")
if l.fire > 0 {
l.log.WithField(durationKey, l.duration).Debug("put out fire")

l.fire--
}
case <-ticker.C:
Expand Down

0 comments on commit de2988a

Please sign in to comment.