* this throttle is to avoid overloading the router */
MAX_CONNECTIONS_PER_SECOND = 32,
- /* number of unchoked peers per torrent.
- * FIXME: this probably ought to be configurable */
- MAX_UNCHOKED_PEERS = 14,
-
/* number of bad pieces a peer is allowed to send before we ban them */
MAX_BAD_PIECES_PER_PEER = 5,
const int peerCount = tr_ptrArraySize( &t->peers );
tr_peer ** peers = (tr_peer**) tr_ptrArrayBase( &t->peers );
struct ChokeData * choke = tr_new0( struct ChokeData, peerCount );
+ const tr_session * session = t->manager->session;
const int chokeAll = !tr_torrentIsPieceTransferAllowed( t->tor, TR_CLIENT_TO_PEER );
const uint64_t now = tr_date( );
* rate to decide which peers to unchoke.
*/
unchokedInterested = 0;
- for( i=0; i<size && unchokedInterested<MAX_UNCHOKED_PEERS; ++i ) {
+ for( i=0; i<size && unchokedInterested<session->uploadSlotsPerTorrent; ++i ) {
choke[i].doUnchoke = 1;
if( choke[i].isInterested )
++unchokedInterested;
tr_bencDictAddInt( d, TR_PREFS_KEY_RPC_PORT, atoi( TR_DEFAULT_RPC_PORT_STR ) );
tr_bencDictAddInt( d, TR_PREFS_KEY_USPEED, 100 );
tr_bencDictAddInt( d, TR_PREFS_KEY_USPEED_ENABLED, 0 );
+ tr_bencDictAddInt( d, TR_PREFS_KEY_UPLOAD_SLOTS_PER_TORRENT, 14 );
}
void
tr_bencDictAddInt( d, TR_PREFS_KEY_RPC_WHITELIST_ENABLED, tr_sessionGetRPCWhitelistEnabled( s ) );
tr_bencDictAddInt( d, TR_PREFS_KEY_USPEED, tr_sessionGetSpeedLimit( s, TR_UP ) );
tr_bencDictAddInt( d, TR_PREFS_KEY_USPEED_ENABLED, tr_sessionIsSpeedLimitEnabled( s, TR_UP ) );
+ tr_bencDictAddInt( d, TR_PREFS_KEY_UPLOAD_SLOTS_PER_TORRENT, s->uploadSlotsPerTorrent );
for( i=0; i<n; ++i )
tr_free( freeme[i] );
/**
**/
+
+ found = tr_bencDictFindInt( &settings, TR_PREFS_KEY_UPLOAD_SLOTS_PER_TORRENT, &i );
+ assert( found );
+ session->uploadSlotsPerTorrent = i;
found = tr_bencDictFindInt( &settings, TR_PREFS_KEY_USPEED, &i )
&& tr_bencDictFindInt( &settings, TR_PREFS_KEY_USPEED_ENABLED, &j );
uint16_t peerLimitPerTorrent;
uint16_t openFileLimit;
+ int uploadSlotsPerTorrent;
+
tr_port peerPort;
tr_port randomPortLow;
tr_port randomPortHigh;
#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_UPLOAD_SLOTS_PER_TORRENT "upload-slots-per-torrent"
struct tr_benc;