1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 17:17:31 +00:00

(trunk libT) finally get around to making upload-slots-per-torrent a settings.json option, thanks to friendly prodding from ful in #transmission

This commit is contained in:
Charles Kerr 2009-01-09 15:45:44 +00:00
parent f7db63329d
commit 2702fc289a
4 changed files with 11 additions and 5 deletions

View file

@ -67,10 +67,6 @@ enum
* this throttle is to avoid overloading the router */ * this throttle is to avoid overloading the router */
MAX_CONNECTIONS_PER_SECOND = 32, 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 */ /* number of bad pieces a peer is allowed to send before we ban them */
MAX_BAD_PIECES_PER_PEER = 5, MAX_BAD_PIECES_PER_PEER = 5,
@ -1932,6 +1928,7 @@ rechoke( Torrent * t )
const int peerCount = tr_ptrArraySize( &t->peers ); const int peerCount = tr_ptrArraySize( &t->peers );
tr_peer ** peers = (tr_peer**) tr_ptrArrayBase( &t->peers ); tr_peer ** peers = (tr_peer**) tr_ptrArrayBase( &t->peers );
struct ChokeData * choke = tr_new0( struct ChokeData, peerCount ); 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 int chokeAll = !tr_torrentIsPieceTransferAllowed( t->tor, TR_CLIENT_TO_PEER );
const uint64_t now = tr_date( ); const uint64_t now = tr_date( );
@ -1981,7 +1978,7 @@ rechoke( Torrent * t )
* rate to decide which peers to unchoke. * rate to decide which peers to unchoke.
*/ */
unchokedInterested = 0; 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; choke[i].doUnchoke = 1;
if( choke[i].isInterested ) if( choke[i].isInterested )
++unchokedInterested; ++unchokedInterested;

View file

@ -253,6 +253,7 @@ tr_sessionGetDefaultSettings( tr_benc * d )
tr_bencDictAddInt( d, TR_PREFS_KEY_RPC_PORT, atoi( TR_DEFAULT_RPC_PORT_STR ) ); 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, 100 );
tr_bencDictAddInt( d, TR_PREFS_KEY_USPEED_ENABLED, 0 ); tr_bencDictAddInt( d, TR_PREFS_KEY_USPEED_ENABLED, 0 );
tr_bencDictAddInt( d, TR_PREFS_KEY_UPLOAD_SLOTS_PER_TORRENT, 14 );
} }
void void
@ -297,6 +298,7 @@ tr_sessionGetSettings( tr_session * s, struct tr_benc * d )
tr_bencDictAddInt( d, TR_PREFS_KEY_RPC_WHITELIST_ENABLED, tr_sessionGetRPCWhitelistEnabled( s ) ); 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, tr_sessionGetSpeedLimit( s, TR_UP ) );
tr_bencDictAddInt( d, TR_PREFS_KEY_USPEED_ENABLED, tr_sessionIsSpeedLimitEnabled( 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 ) for( i=0; i<n; ++i )
tr_free( freeme[i] ); tr_free( freeme[i] );
@ -492,6 +494,10 @@ tr_sessionInit( const char * tag,
/** /**
**/ **/
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 ) found = tr_bencDictFindInt( &settings, TR_PREFS_KEY_USPEED, &i )
&& tr_bencDictFindInt( &settings, TR_PREFS_KEY_USPEED_ENABLED, &j ); && tr_bencDictFindInt( &settings, TR_PREFS_KEY_USPEED_ENABLED, &j );

View file

@ -76,6 +76,8 @@ struct tr_session
uint16_t peerLimitPerTorrent; uint16_t peerLimitPerTorrent;
uint16_t openFileLimit; uint16_t openFileLimit;
int uploadSlotsPerTorrent;
tr_port peerPort; tr_port peerPort;
tr_port randomPortLow; tr_port randomPortLow;
tr_port randomPortHigh; tr_port randomPortHigh;

View file

@ -155,6 +155,7 @@ tr_encryption_mode;
#define TR_PREFS_KEY_RPC_WHITELIST "rpc-whitelist" #define TR_PREFS_KEY_RPC_WHITELIST "rpc-whitelist"
#define TR_PREFS_KEY_USPEED_ENABLED "upload-limit-enabled" #define TR_PREFS_KEY_USPEED_ENABLED "upload-limit-enabled"
#define TR_PREFS_KEY_USPEED "upload-limit" #define TR_PREFS_KEY_USPEED "upload-limit"
#define TR_PREFS_KEY_UPLOAD_SLOTS_PER_TORRENT "upload-slots-per-torrent"
struct tr_benc; struct tr_benc;