Skip to content

Commit

Permalink
fix: Fixes possible wrong lost events count
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkheir committed Jan 3, 2023
1 parent 6fba496 commit 97a24fd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions reassembler.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (l *eventList) remove() {
}

// Clear removes all events from the list and returns the events and the number
// of list events.
// of lost events.
func (l *eventList) Clear() ([]*event, int) {
l.Lock()
defer l.Unlock()
Expand All @@ -243,7 +243,7 @@ func (l *eventList) Clear() ([]*event, int) {
event := l.events[seq]

if l.lastSeq > 0 {
lost += int(seq - l.lastSeq - 1)
lost += int(seq) - int(l.lastSeq) - 1
}
l.lastSeq = seq
evicted = append(evicted, event)
Expand Down Expand Up @@ -302,7 +302,7 @@ func (l *eventList) CleanUp() ([]*event, int) {

if event.complete || size > l.maxSize || event.IsExpired() {
if l.lastSeq > 0 {
lost += int(seq - l.lastSeq - 1)
lost += int(seq) - int(l.lastSeq) - 1
}
l.lastSeq = seq
evicted = append(evicted, event)
Expand Down

0 comments on commit 97a24fd

Please sign in to comment.