Skip to content

Commit

Permalink
use local var to avoid race on close
Browse files Browse the repository at this point in the history
  • Loading branch information
mh0lt committed Aug 4, 2024
1 parent 6164078 commit 243ff4c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions torrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2857,10 +2857,13 @@ func (t *Torrent) tryCreatePieceHasher(lock bool) bool {
})

t.mu.RLock()
if hashResults := t.hashResults; hashResults != nil {
hashResults <- hashResult{p.index, correct, failedPeers, copyErr}
}
hashResults := t.hashResults
t.mu.RUnlock()

select {
case hashResults <- hashResult{p.index, correct, failedPeers, copyErr}:
case <-t.closed.Done():
}
}
}()

Expand Down

0 comments on commit 243ff4c

Please sign in to comment.