]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Inlineable `DownloadPieces()` and `CancelPieces()` (#623)
authorYenForYang <YenForYang@users.noreply.github.com>
Wed, 15 Sep 2021 00:13:46 +0000 (19:13 -0500)
committerGitHub <noreply@github.com>
Wed, 15 Sep 2021 00:13:46 +0000 (10:13 +1000)
t.go

diff --git a/t.go b/t.go
index b42a3f0f2c1c29f0ec9d2bbf5f19f6c2aca135ce..3f65d48ba88f76521d4ac3bdea42164024d79646 100644 (file)
--- a/t.go
+++ b/t.go
@@ -180,8 +180,8 @@ func (t *Torrent) deleteReader(r *reader) {
 // has been obtained, see Torrent.Info and Torrent.GotInfo.
 func (t *Torrent) DownloadPieces(begin, end pieceIndex) {
        t.cl.lock()
-       defer t.cl.unlock()
        t.downloadPiecesLocked(begin, end)
+       t.cl.unlock()
 }
 
 func (t *Torrent) downloadPiecesLocked(begin, end pieceIndex) {
@@ -194,8 +194,8 @@ func (t *Torrent) downloadPiecesLocked(begin, end pieceIndex) {
 
 func (t *Torrent) CancelPieces(begin, end pieceIndex) {
        t.cl.lock()
-       defer t.cl.unlock()
        t.cancelPiecesLocked(begin, end)
+       t.cl.unlock()
 }
 
 func (t *Torrent) cancelPiecesLocked(begin, end pieceIndex) {