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 3, 2024
1 parent b09452a commit 10f8862
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion torrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2856,7 +2856,13 @@ func (t *Torrent) tryCreatePieceHasher(lock bool) bool {
cs.pieceHashed(length)
})

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

if hashResults != nil {
hashResults <- hashResult{p.index, correct, failedPeers, copyErr}
}
}
}()

Expand Down

0 comments on commit 10f8862

Please sign in to comment.