(trunk libT) #4931 "Wrong peer percentages for magnetized transfers" -- fixed.

tr_peerUpdateProgress() is guessing at the progress size, but when we don't have the data size yet that guess isn't very good. Add boundary
 clamps on the peer.progress field.
This commit is contained in:
Jordan Lee 2012-07-01 02:00:02 +00:00
parent df80c1ce03
commit 99b615b3b8
1 changed files with 10 additions and 0 deletions

View File

@ -2494,11 +2494,21 @@ tr_peerUpdateProgress( tr_torrent * tor, tr_peer * peer )
const float true_count = tr_bitfieldCountTrueBits( have );
if( tr_torrentHasMetadata( tor ) )
{
peer->progress = true_count / tor->info.pieceCount;
}
else /* without pieceCount, this result is only a best guess... */
{
peer->progress = true_count / ( have->bit_count + 1 );
}
}
/* clamp the progress range */
if ( peer->progress < 0.0 )
peer->progress = 0.0;
if ( peer->progress > 1.0 )
peer->progress = 1.0;
if( peer->atom && ( peer->progress >= 1.0 ) )
atomSetSeed( tor->torrentPeers, peer->atom );
}