Skip to content

Commit

Permalink
process close done
Browse files Browse the repository at this point in the history
  • Loading branch information
mh0lt committed Aug 4, 2024
1 parent eeefd76 commit 0cd7405
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion torrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2890,14 +2890,25 @@ func (t *Torrent) processHashResults(hashResults chan hashResult) {
defer cancel()

for !t.closed.IsSet() {
results := []hashResult{<-hashResults}
results := []hashResult{}

select {
case result, ok := <-hashResults:
if ok {
results = append(results, result)
}
case <-t.closed.Done():
return
}

for done := false; !done; {
select {
case result, ok := <-hashResults:
if ok {
results = append(results, result)
}
case <-t.closed.Done():
return
default:
done = true
}
Expand Down

0 comments on commit 0cd7405

Please sign in to comment.