From: Matt Joiner Date: Sun, 28 Jan 2018 04:52:14 +0000 (+1100) Subject: Remove premature update to piece priority after piece is completed X-Git-Tag: v1.0.0~253 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=de928be5828fe66cf0f3c41e1933ecda5ae8a6f6;p=btrtrc.git Remove premature update to piece priority after piece is completed This should have prevented Torrent.piecePriorityChanged from being called, meaning requests for the completed piece were not canceled, and the piece remained in connection's piece request queue, which meant wasted effort downloading chunks for an already acquired piece. Thanks to @elgatito for discovering the issue. --- diff --git a/torrent.go b/torrent.go index 18176156..7063969b 100644 --- a/torrent.go +++ b/torrent.go @@ -1515,7 +1515,6 @@ func (t *Torrent) cancelRequestsForPiece(piece int) { } func (t *Torrent) onPieceCompleted(piece int) { - t.pendingPieces.Remove(piece) t.pendAllChunkSpecs(piece) t.cancelRequestsForPiece(piece) for conn := range t.conns {