#endif
}
-static int
-checkRatioIdle( void * tor )
-{
- tr_torrentCheckSeedRatio( tor );
- return 0; /* one-shot timer */
-}
-
static void
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;
}
static int
bandwidthPulse( void * vmgr )
{
+ tr_torrent * tor = NULL;
tr_peerMgr * mgr = vmgr;
managerLock( mgr );
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;
}
tr_torrent * tor = NULL;
while(( tor = tr_torrentNext( session, tor )))
- tr_torrentCheckSeedRatio( tor );
+ tor->needsSeedRatioCheck = TRUE;
}
void
assert( mode==TR_RATIOLIMIT_GLOBAL || mode==TR_RATIOLIMIT_SINGLE || mode==TR_RATIOLIMIT_UNLIMITED );
tor->ratioLimitMode = mode;
-
- tr_torrentCheckSeedRatio( tor );
+ tor->needsSeedRatioCheck = TRUE;
}
tr_ratiolimit
}
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
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 );
tor->startDate = tor->anyDate = time( NULL );
tr_trackerStart( tor->tracker );
tr_peerMgrStartTorrent( tor );
- tr_torrentCheckSeedRatio( tor );
tr_globalUnlock( tor->session );
}
}
tor->completeness = completeness;
+ tor->needsSeedRatioCheck = TRUE;
tr_torrentCloseLocalFiles( tor );
fireCompletenessChange( tor, completeness );
}
tr_torrentSaveResume( tor );
- tr_torrentCheckSeedRatio( tor );
}
tr_torrentUnlock( 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 );
}
tr_bool isRunning;
tr_bool isDeleting;
+ tr_bool needsSeedRatioCheck;
uint16_t maxConnectedPeers;
#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"
#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;