diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index b938c2af6..bc2cd39fe 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -67,10 +67,6 @@ enum * 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, @@ -1932,6 +1928,7 @@ rechoke( Torrent * t ) 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( ); @@ -1981,7 +1978,7 @@ rechoke( Torrent * t ) * rate to decide which peers to unchoke. */ unchokedInterested = 0; - for( i=0; iuploadSlotsPerTorrent; ++i ) { choke[i].doUnchoke = 1; if( choke[i].isInterested ) ++unchokedInterested; diff --git a/libtransmission/session.c b/libtransmission/session.c index fdad8659a..f9cdddd86 100644 --- a/libtransmission/session.c +++ b/libtransmission/session.c @@ -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_USPEED, 100 ); tr_bencDictAddInt( d, TR_PREFS_KEY_USPEED_ENABLED, 0 ); + tr_bencDictAddInt( d, TR_PREFS_KEY_UPLOAD_SLOTS_PER_TORRENT, 14 ); } 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_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; iuploadSlotsPerTorrent = i; found = tr_bencDictFindInt( &settings, TR_PREFS_KEY_USPEED, &i ) && tr_bencDictFindInt( &settings, TR_PREFS_KEY_USPEED_ENABLED, &j ); diff --git a/libtransmission/session.h b/libtransmission/session.h index f3cee19f5..c14d339ec 100644 --- a/libtransmission/session.h +++ b/libtransmission/session.h @@ -76,6 +76,8 @@ struct tr_session uint16_t peerLimitPerTorrent; uint16_t openFileLimit; + int uploadSlotsPerTorrent; + tr_port peerPort; tr_port randomPortLow; tr_port randomPortHigh; diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index f092d7ba0..9d6ed4588 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -155,6 +155,7 @@ tr_encryption_mode; #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;