(trunk libT) another possible fix for #1894: Crash when download finishes and seed ratio is already met
This commit is contained in:
parent
cac4909bf6
commit
81766a8dcb
|
@ -995,13 +995,6 @@ peerSuggestedPiece( Torrent * t UNUSED,
|
|||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
checkRatioIdle( void * tor )
|
||||
{
|
||||
tr_torrentCheckSeedRatio( tor );
|
||||
return 0; /* one-shot timer */
|
||||
}
|
||||
|
||||
static void
|
||||
peerCallbackFunc( void * vpeer, void * vevent, void * vt )
|
||||
{
|
||||
|
@ -1050,11 +1043,7 @@ peerCallbackFunc( void * vpeer, void * vevent, void * vt )
|
|||
a->piece_data_time = now;
|
||||
}
|
||||
|
||||
/* we can't check the stop ratio here because the code calling
|
||||
* this function requires that the torrent not be stopped.
|
||||
* so instead, add an idle timer to check the ratio as soon
|
||||
* as the calling code is done. (ticket #1894) */
|
||||
tr_timerNew( tor->session, checkRatioIdle, tor, 1 );
|
||||
tor->needsSeedRatioCheck = TRUE;
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -2431,6 +2420,7 @@ pumpAllPeers( tr_peerMgr * mgr )
|
|||
static int
|
||||
bandwidthPulse( void * vmgr )
|
||||
{
|
||||
tr_torrent * tor = NULL;
|
||||
tr_peerMgr * mgr = vmgr;
|
||||
managerLock( mgr );
|
||||
|
||||
|
@ -2441,6 +2431,14 @@ bandwidthPulse( void * vmgr )
|
|||
tr_bandwidthAllocate( mgr->session->bandwidth, TR_UP, BANDWIDTH_PERIOD_MSEC );
|
||||
tr_bandwidthAllocate( mgr->session->bandwidth, TR_DOWN, BANDWIDTH_PERIOD_MSEC );
|
||||
|
||||
/* possibly stop torrents that have seeded enough */
|
||||
while(( tor = tr_torrentNext( mgr->session, tor ))) {
|
||||
if( tor->needsSeedRatioCheck ) {
|
||||
tor->needsSeedRatioCheck = FALSE;
|
||||
tr_torrentCheckSeedRatio( tor );
|
||||
}
|
||||
}
|
||||
|
||||
managerUnlock( mgr );
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -865,7 +865,7 @@ updateSeedRatio( tr_session * session )
|
|||
tr_torrent * tor = NULL;
|
||||
|
||||
while(( tor = tr_torrentNext( session, tor )))
|
||||
tr_torrentCheckSeedRatio( tor );
|
||||
tor->needsSeedRatioCheck = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -172,8 +172,7 @@ tr_torrentSetRatioMode( tr_torrent * tor, tr_ratiolimit mode )
|
|||
assert( mode==TR_RATIOLIMIT_GLOBAL || mode==TR_RATIOLIMIT_SINGLE || mode==TR_RATIOLIMIT_UNLIMITED );
|
||||
|
||||
tor->ratioLimitMode = mode;
|
||||
|
||||
tr_torrentCheckSeedRatio( tor );
|
||||
tor->needsSeedRatioCheck = TRUE;
|
||||
}
|
||||
|
||||
tr_ratiolimit
|
||||
|
@ -185,14 +184,13 @@ tr_torrentGetRatioMode( const tr_torrent * tor )
|
|||
}
|
||||
|
||||
void
|
||||
tr_torrentSetRatioLimit( tr_torrent * tor,
|
||||
double desiredRatio )
|
||||
tr_torrentSetRatioLimit( tr_torrent * tor, double desiredRatio )
|
||||
{
|
||||
assert( tr_isTorrent( tor ) );
|
||||
|
||||
tor->desiredRatio = desiredRatio;
|
||||
|
||||
tr_torrentCheckSeedRatio( tor );
|
||||
tor->needsSeedRatioCheck = TRUE;
|
||||
}
|
||||
|
||||
double
|
||||
|
@ -1192,7 +1190,8 @@ checkAndStartImpl( void * vtor )
|
|||
|
||||
tr_globalLock( tor->session );
|
||||
|
||||
tor->isRunning = 1;
|
||||
tor->isRunning = TRUE;
|
||||
tor->needsSeedRatioCheck = TRUE;
|
||||
*tor->errorString = '\0';
|
||||
tr_torrentResetTransferStats( tor );
|
||||
tor->completeness = tr_cpGetStatus( &tor->completion );
|
||||
|
@ -1200,7 +1199,6 @@ checkAndStartImpl( void * vtor )
|
|||
tor->startDate = tor->anyDate = time( NULL );
|
||||
tr_trackerStart( tor->tracker );
|
||||
tr_peerMgrStartTorrent( tor );
|
||||
tr_torrentCheckSeedRatio( tor );
|
||||
|
||||
tr_globalUnlock( tor->session );
|
||||
}
|
||||
|
@ -1470,6 +1468,7 @@ tr_torrentRecheckCompleteness( tr_torrent * tor )
|
|||
}
|
||||
|
||||
tor->completeness = completeness;
|
||||
tor->needsSeedRatioCheck = TRUE;
|
||||
tr_torrentCloseLocalFiles( tor );
|
||||
fireCompletenessChange( tor, completeness );
|
||||
|
||||
|
@ -1481,7 +1480,6 @@ tr_torrentRecheckCompleteness( tr_torrent * tor )
|
|||
}
|
||||
|
||||
tr_torrentSaveResume( tor );
|
||||
tr_torrentCheckSeedRatio( tor );
|
||||
}
|
||||
|
||||
tr_torrentUnlock( tor );
|
||||
|
@ -1654,7 +1652,7 @@ tr_torrentInitFileDLs( tr_torrent * tor,
|
|||
for( i=0; i<fileCount; ++i )
|
||||
setFileDND( tor, files[i], doDownload );
|
||||
tr_cpInvalidateDND( &tor->completion );
|
||||
tr_torrentCheckSeedRatio( tor );
|
||||
tor->needsSeedRatioCheck = TRUE;
|
||||
|
||||
tr_torrentUnlock( tor );
|
||||
}
|
||||
|
|
|
@ -199,6 +199,7 @@ struct tr_torrent
|
|||
|
||||
tr_bool isRunning;
|
||||
tr_bool isDeleting;
|
||||
tr_bool needsSeedRatioCheck;
|
||||
|
||||
uint16_t maxConnectedPeers;
|
||||
|
||||
|
|
|
@ -169,8 +169,6 @@ static TR_INLINE tr_bool tr_isEncryptionMode( tr_encryption_mode m )
|
|||
#define TR_PREFS_KEY_ALT_SPEED_TIME_DAY "alt-speed-time-day"
|
||||
#define TR_PREFS_KEY_BLOCKLIST_ENABLED "blocklist-enabled"
|
||||
#define TR_PREFS_KEY_DOWNLOAD_DIR "download-dir"
|
||||
#define TR_PREFS_KEY_DSPEED "download-limit"
|
||||
#define TR_PREFS_KEY_DSPEED_ENABLED "download-limit-enabled"
|
||||
#define TR_PREFS_KEY_ENCRYPTION "encryption"
|
||||
#define TR_PREFS_KEY_LAZY_BITFIELD "lazy-bitfield-enabled"
|
||||
#define TR_PREFS_KEY_MSGLEVEL "message-level"
|
||||
|
@ -201,8 +199,10 @@ static TR_INLINE tr_bool tr_isEncryptionMode( tr_encryption_mode m )
|
|||
#define TR_PREFS_KEY_RPC_USERNAME "rpc-username"
|
||||
#define TR_PREFS_KEY_RPC_WHITELIST_ENABLED "rpc-whitelist-enabled"
|
||||
#define TR_PREFS_KEY_RPC_WHITELIST "rpc-whitelist"
|
||||
#define TR_PREFS_KEY_USPEED_ENABLED "upload-limit-enabled"
|
||||
#define TR_PREFS_KEY_USPEED "upload-limit"
|
||||
#define TR_PREFS_KEY_DSPEED "speed-limit-down"
|
||||
#define TR_PREFS_KEY_DSPEED_ENABLED "speed-limit-down-enabled"
|
||||
#define TR_PREFS_KEY_USPEED_ENABLED "speed-limit-up-enabled"
|
||||
#define TR_PREFS_KEY_USPEED "speed-limit-up"
|
||||
#define TR_PREFS_KEY_UPLOAD_SLOTS_PER_TORRENT "upload-slots-per-torrent"
|
||||
|
||||
struct tr_benc;
|
||||
|
|
Loading…
Reference in New Issue