From 400fa1feaf151c2957621914f1df47391fe68027 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sun, 21 Feb 2016 03:33:39 +1100 Subject: [PATCH] Fix race updating piece priority when piece being read is unexpectedly unavailable --- reader.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/reader.go b/reader.go index 12caf4ca..0f92343a 100644 --- a/reader.go +++ b/reader.go @@ -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() } }