Skip to content

Commit cc8650f

Browse files
committed
Stop sticky piece hasher from hashing new pieces after torrent close
Check t.closed in the pieceHasher loop before picking up new pieces. Without this, the hasher goroutine could start hashing pieces against already-closed storage after Drop(), causing "file already closed" warnings visible in BenchmarkAddLargeTorrent.
1 parent 1641c45 commit cc8650f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

torrent.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,6 +2784,9 @@ func (t *Torrent) startSinglePieceHasher() bool {
27842784
func (t *Torrent) pieceHasher(initial pieceIndex) {
27852785
t.finishHash(initial)
27862786
for {
2787+
if t.closed.IsSet() {
2788+
break
2789+
}
27872790
piOpt := t.getPieceToHash()
27882791
if !piOpt.Ok {
27892792
break

0 commit comments

Comments
 (0)