From: Matt Joiner Date: Tue, 9 Dec 2014 06:22:05 +0000 (-0600) Subject: Fixes due to not pending chunk specs prematurely X-Git-Tag: v1.0.0~1396 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=262f045fd1846b43861531f099c28015e132912e;p=btrtrc.git Fixes due to not pending chunk specs prematurely --- diff --git a/client.go b/client.go index aeff48c0..602f99c7 100644 --- 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 { diff --git a/torrent.go b/torrent.go index 891e0060..469d2b15 100644 --- a/torrent.go +++ b/torrent.go @@ -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))