Fix race updating piece priority when piece being read is unexpectedly unavailable

This commit is contained in:
Matt Joiner 2016-02-21 03:33:39 +11:00
parent e20858a1e8
commit 400fa1feaf
1 changed files with 2 additions and 0 deletions

View File

@ -135,8 +135,10 @@ func (r *Reader) readOnceAt(b []byte, pos int64) (n int, err error) {
return
}
log.Printf("%s: error reading from torrent storage pos=%d: %s", r.t, pos, err)
r.t.cl.mu.Lock()
r.t.torrent.updatePieceCompletion(pi)
r.t.torrent.updatePiecePriority(pi)
r.t.cl.mu.Unlock()
}
}