]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fixes due to not pending chunk specs prematurely
authorMatt Joiner <anacrolix@gmail.com>
Tue, 9 Dec 2014 06:22:05 +0000 (00:22 -0600)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 9 Dec 2014 06:22:05 +0000 (00:22 -0600)
client.go
torrent.go

index aeff48c0b8a0eb257edeeb1490a186feb5facdb8..602f99c7bd983f873d8146935fea44109a6848fd 100644 (file)
--- a/client.go
+++ b/client.go
@@ -941,6 +941,7 @@ func (me *Client) runConnection(sock net.Conn, torrent *torrent, discovery peerS
        }
        if torrent.haveInfo() {
                torrent.initRequestOrdering(conn)
+               me.replenishConnRequests(torrent, conn)
        }
        err = me.connectionLoop(torrent, conn)
        if err != nil {
@@ -2139,7 +2140,8 @@ func (me *Client) pieceHashed(t *torrent, piece pp.Integer, correct bool) {
                        conn.pieceRequestOrder.DeletePiece(int(piece))
                }
                if t.wantPiece(int(piece)) && conn.PeerHasPiece(piece) {
-                       conn.pendPiece(int(piece), t.Pieces[piece].Priority)
+                       t.connPendPiece(conn, int(piece))
+                       me.replenishConnRequests(t, conn)
                }
        }
        if t.haveAllPieces() && me.noUpload {
index 891e0060b6c93ee3d21adc48fbfdb84183607d33..469d2b15f11ed9fd3e5d165a90573a45a8112d82 100644 (file)
@@ -21,6 +21,10 @@ import (
 )
 
 func (t *torrent) PieceNumPendingBytes(index pp.Integer) (count pp.Integer) {
+       piece := t.Pieces[index]
+       if !piece.EverHashed {
+               return t.PieceLength(index)
+       }
        pendingChunks := t.Pieces[index].PendingChunkSpecs
        count = pp.Integer(len(pendingChunks)) * chunkSize
        _lastChunkSpec := lastChunkSpec(t.PieceLength(index))