]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Switch to Client read locks for a few methods
authorMatt Joiner <anacrolix@gmail.com>
Tue, 8 Jan 2019 04:46:03 +0000 (15:46 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 8 Jan 2019 04:46:03 +0000 (15:46 +1100)
t.go

diff --git a/t.go b/t.go
index 043262066fe8a73b4d30e8f7c2a2ed14b065ab1a..8af13dc2a16b5773782946635ecb7c473b4a2a82 100644 (file)
--- a/t.go
+++ b/t.go
@@ -45,14 +45,14 @@ func (t *Torrent) NewReader() Reader {
 // same state. The sum of the state run lengths is the number of pieces
 // in the torrent.
 func (t *Torrent) PieceStateRuns() []PieceStateRun {
-       t.cl.lock()
-       defer t.cl.unlock()
+       t.cl.rLock()
+       defer t.cl.rUnlock()
        return t.pieceStateRuns()
 }
 
 func (t *Torrent) PieceState(piece pieceIndex) PieceState {
-       t.cl.lock()
-       defer t.cl.unlock()
+       t.cl.rLock()
+       defer t.cl.rUnlock()
        return t.pieceState(piece)
 }