Skip to content

Commit 3619476

Browse files
committed
fix: Fixes possible wrong lost events count
1 parent 6fba496 commit 3619476

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

reassembler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func (l *eventList) remove() {
224224
}
225225

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

245245
if l.lastSeq > 0 {
246-
lost += int(seq - l.lastSeq - 1)
246+
lost += int(seq) - int(l.lastSeq) - 1
247247
}
248248
l.lastSeq = seq
249249
evicted = append(evicted, event)
@@ -302,7 +302,7 @@ func (l *eventList) CleanUp() ([]*event, int) {
302302

303303
if event.complete || size > l.maxSize || event.IsExpired() {
304304
if l.lastSeq > 0 {
305-
lost += int(seq - l.lastSeq - 1)
305+
lost += int(seq) - int(l.lastSeq) - 1
306306
}
307307
l.lastSeq = seq
308308
evicted = append(evicted, event)

0 commit comments

Comments
 (0)