]> granicus.if.org Git - transmission/commitdiff
(trunk libT) finally get around to making upload-slots-per-torrent a settings.json...
authorCharles Kerr <charles@transmissionbt.com>
Fri, 9 Jan 2009 15:45:44 +0000 (15:45 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Fri, 9 Jan 2009 15:45:44 +0000 (15:45 +0000)
libtransmission/peer-mgr.c
libtransmission/session.c
libtransmission/session.h
libtransmission/transmission.h

index b938c2af610f2b1c677e27368a7c985ba32897e6..bc2cd39fee8069161ccdea9f9a86169b4176a3e0 100644 (file)
@@ -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; 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;
index fdad8659a9a73ed4ff549d742a0fd3e35fb2ac9e..f9cdddd86632c5ea20bd4ee73274a85ca734d827 100644 (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_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; i<n; ++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 )
          && tr_bencDictFindInt( &settings, TR_PREFS_KEY_USPEED_ENABLED, &j );
index f3cee19f5e3f8d550c1f4996d0509f0ea51cfc86..c14d339ec84dcfd90cd594053a33c2fcf81704b3 100644 (file)
@@ -76,6 +76,8 @@ struct tr_session
     uint16_t                     peerLimitPerTorrent;
     uint16_t                     openFileLimit;
 
+    int                          uploadSlotsPerTorrent;
+
     tr_port                      peerPort;
     tr_port                      randomPortLow;
     tr_port                      randomPortHigh;
index f092d7ba099fbef61ad3d210d125d7988f5f720e..9d6ed45887fa89313a534759df67eaef6b8805cb 100644 (file)
@@ -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;