From: Matt Joiner Date: Tue, 8 Jan 2019 04:46:03 +0000 (+1100) Subject: Switch to Client read locks for a few methods X-Git-Tag: v1.0.0~1 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=366ead7d658dd4bd925badbedcd096edfed56249;p=btrtrc.git Switch to Client read locks for a few methods --- diff --git a/t.go b/t.go index 04326206..8af13dc2 100644 --- 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) }