1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 09:37:56 +00:00

(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

View file

@ -2494,10 +2494,20 @@ 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 );