Skip to content

Commit

Permalink
fix queue potential leak
Browse files Browse the repository at this point in the history
  • Loading branch information
Termina1 committed Sep 6, 2024
1 parent 523476c commit d75b800
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions utils/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ func (q *FDQueue[S, E]) Feed() (recs S, err error) {
return
case <-time.After(q.timeout):
return
case pkg := <-q.ch:
case pkg, ok := <-q.ch:
if !ok {
return
}
recs = append(recs, pkg)
for ok := false; ok; {
pkg, ok = <-q.ch
recs = append(recs, pkg)
if len(q.ch) == 0 {
return
}
return
}
return
}

0 comments on commit d75b800

Please sign in to comment.