]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix race updating piece priority when piece being read is unexpectedly unavailable
authorMatt Joiner <anacrolix@gmail.com>
Sat, 20 Feb 2016 16:33:39 +0000 (03:33 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 20 Feb 2016 16:33:39 +0000 (03:33 +1100)
reader.go

index 12caf4cad06d16c37dcfa1079edd66d4f8ade975..0f92343a20c3b448d8567b8e37a2071836f030a7 100644 (file)
--- 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()
        }
 }