Fixes due to not pending chunk specs prematurely

This commit is contained in:
Matt Joiner 2014-12-09 00:22:05 -06:00
parent 998d85ba50
commit 262f045fd1
2 changed files with 7 additions and 1 deletions

View File

@ -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 {

View 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))