(libT) #3453:Torrent does not stop when set per torrent seed ratio is reached before torrent is completed

(libT) #3578:Interested flag isn't cleared when transitioning from leeching to seeding
This commit is contained in:
Daniel Lee 2010-09-25 00:34:15 +00:00
parent d57ba48775
commit afc7c5355e
3 changed files with 40 additions and 3 deletions

View File

@ -2384,6 +2384,30 @@ tr_peerMgrPeerStats( const tr_torrent * tor,
***
**/
void
tr_peerMgrClearInterest( tr_torrent * tor )
{
int i;
Torrent * t;
int peerCount;
assert( tr_isTorrent( tor ) );
t = tor->torrentPeers;
torrentLock( t );
peerCount = tr_ptrArraySize( &t->peers );
for( i=0; i<peerCount; ++i )
{
const tr_peer * peer = tr_ptrArrayNth( &t->peers, i );
tr_peerMsgsSetInterested( peer->msgs, FALSE );
}
torrentUnlock( t );
}
/* do we still want this piece and does the peer have it? */
static tr_bool
isPieceInteresting( const tr_torrent * tor, const tr_peer * peer, tr_piece_index_t index )

View File

@ -234,6 +234,8 @@ int tr_peerGetPieceSpeed_Bps( const tr_peer * peer,
uint64_t now,
tr_direction direction );
void tr_peerMgrClearInterest( tr_torrent * tor );
/* @} */
#endif

View File

@ -1599,8 +1599,10 @@ verifyTorrent( void * vtor )
/* if the torrent's running, stop it & set the restart-after-verify flag */
if( tor->startAfterVerify || tor->isRunning ) {
/* don't clobber isStopping */
const tr_bool startAfter = tor->isStopping ? FALSE : TRUE;
tr_torrentStop( tor );
tor->startAfterVerify = TRUE;
tor->startAfterVerify = startAfter;
}
/* add the torrent to the recheck queue */
@ -1847,7 +1849,6 @@ torrentCallScript( tr_torrent * tor, const char * script )
void
tr_torrentRecheckCompleteness( tr_torrent * tor )
{
tr_bool wasRunning;
tr_completeness completeness;
assert( tr_isTorrent( tor ) );
@ -1855,11 +1856,12 @@ tr_torrentRecheckCompleteness( tr_torrent * tor )
tr_torrentLock( tor );
completeness = tr_cpGetStatus( &tor->completion );
wasRunning = tor->isRunning;
if( completeness != tor->completeness )
{
const int recentChange = tor->downloadedCur != 0;
const tr_bool wasLeeching = !tr_torrentIsSeed( tor );
const tr_bool wasRunning = tor->isRunning;
if( recentChange )
{
@ -1879,6 +1881,15 @@ tr_torrentRecheckCompleteness( tr_torrent * tor )
tor->doneDate = tor->anyDate = tr_time( );
}
if( wasLeeching && wasRunning )
{
/* clear interested flag on all peers */
tr_peerMgrClearInterest( tor );
/* if completeness was TR_LEECH then the seed limit check will have been skipped in bandwidthPulse */
tr_torrentCheckSeedLimit( tor );
}
if( tor->currentDir == tor->incompleteDir )
tr_torrentSetLocation( tor, tor->downloadDir, TRUE, NULL, NULL );