]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix rare single-torrent stall due to obsolete ceaseNetworking call
authorMatt Joiner <anacrolix@gmail.com>
Wed, 3 Jun 2015 12:43:40 +0000 (22:43 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 3 Jun 2015 12:43:40 +0000 (22:43 +1000)
Only occurred if you have a data backend that can drop completed pieces, and it happened that you wanted to redownload data that had been dropped after completely downloading the torrent in the past.

client.go

index b21fb5223f6a04b49af191d3a1a6446b1c1f33aa..06c1652e6b7084afc3166bcc6ecbef2ea1ba36d8 100644 (file)
--- a/client.go
+++ b/client.go
@@ -337,8 +337,8 @@ func (t *torrent) connPendPiece(c *connection, piece int) {
 
 func (cl *Client) raisePiecePriority(t *torrent, piece int, priority piecePriority) {
        if t.Pieces[piece].Priority < priority {
-               cl.event.Broadcast()
                cl.prioritizePiece(t, piece, priority)
+               cl.event.Broadcast()
        }
 }
 
@@ -2552,6 +2552,7 @@ func (me *Client) pieceHashed(t *torrent, piece pp.Integer, correct bool) {
 func (me *Client) pieceChanged(t *torrent, piece int) {
        correct := t.pieceComplete(piece)
        p := t.Pieces[piece]
+       defer p.Event.Broadcast()
        if correct {
                p.Priority = PiecePriorityNone
                p.PendingChunkSpecs = nil
@@ -2560,7 +2561,6 @@ func (me *Client) pieceChanged(t *torrent, piece int) {
                                delete(t.urgent, req)
                        }
                }
-               p.Event.Broadcast()
        } else {
                if p.numPendingChunks() == 0 {
                        t.pendAllChunkSpecs(int(piece))
@@ -2588,9 +2588,6 @@ func (me *Client) pieceChanged(t *torrent, piece int) {
                        me.replenishConnRequests(t, conn)
                }
        }
-       if t.haveAllPieces() && me.config.NoUpload {
-               t.ceaseNetworking()
-       }
        me.event.Broadcast()
 }