Changeset 10347


Ignore:
Timestamp:
Mar 10, 2010, 3:55:00 PM (12 years ago)
Author:
charles
Message:

(trunk libT) code cleanup: after r10346, we don't need to keep the per-torrent cancel/block histories anymore

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-mgr.c

    r10346 r10347  
    8686    REQUEST_TTL_SECS = 60,
    8787
    88     HISTORY_SEC = TORRENT_DOWNLOAD_CONGESTION_HISTORY_SEC
     88    CANCEL_HISTORY_SEC = 120
    8989};
    9090
     
    347347    atom->peer = peer;
    348348
    349     peer->blocksSentToClient  = tr_historyNew( HISTORY_SEC, 1 );
    350     peer->blocksSentToPeer    = tr_historyNew( HISTORY_SEC, 1 );
    351     peer->cancelsSentToClient = tr_historyNew( HISTORY_SEC, 1 );
    352     peer->cancelsSentToPeer   = tr_historyNew( HISTORY_SEC, 1 );
     349    peer->blocksSentToClient  = tr_historyNew( CANCEL_HISTORY_SEC, 1 );
     350    peer->blocksSentToPeer    = tr_historyNew( CANCEL_HISTORY_SEC, 1 );
     351    peer->cancelsSentToClient = tr_historyNew( CANCEL_HISTORY_SEC, 1 );
     352    peer->cancelsSentToPeer   = tr_historyNew( CANCEL_HISTORY_SEC, 1 );
    353353
    354354    return peer;
     
    11501150                if( ( it->peer != NULL ) && ( it->peer->msgs != NULL ) ) {
    11511151                    tr_historyAdd( it->peer->cancelsSentToPeer, now_msec, 1 );
    1152                     tr_historyAdd( tor->cancelsSentToPeer, now_msec, 1 );
    11531152                    tr_peerMsgsCancel( it->peer->msgs, it->block );
    11541153                    decrementPendingReqCount( it );
     
    13821381        {
    13831382            tr_torrent * tor = t->tor;
    1384             uint64_t now_msec;
    13851383            tr_block_index_t block = _tr_block( tor, e->pieceIndex, e->offset );
    13861384
     
    13881386            pieceListRemoveRequest( t, block );
    13891387
    1390             now_msec = tr_date( );
    1391             tr_historyAdd( tor->blocksSentToClient, now_msec, 1 );
    13921388            if( peer != NULL )
    1393                 tr_historyAdd( peer->blocksSentToClient, now_msec, 1 );
     1389                tr_historyAdd( peer->blocksSentToClient, tr_date( ), 1 );
    13941390
    13951391            if( tr_cpBlockIsComplete( &tor->completion, block ) )
     
    22692265        stat->isSeed              = ( atom->uploadOnly == UPLOAD_ONLY_YES ) || ( peer->progress >= 1.0 );
    22702266
    2271         stat->blocksToPeer        = tr_historyGet( peer->blocksSentToPeer,    now, HISTORY_SEC*1000 );
    2272         stat->blocksToClient      = tr_historyGet( peer->blocksSentToClient,  now, HISTORY_SEC*1000 );
    2273         stat->cancelsToPeer       = tr_historyGet( peer->cancelsSentToPeer,   now, HISTORY_SEC*1000 );
    2274         stat->cancelsToClient     = tr_historyGet( peer->cancelsSentToClient, now, HISTORY_SEC*1000 );
     2267        stat->blocksToPeer        = tr_historyGet( peer->blocksSentToPeer,    now, CANCEL_HISTORY_SEC*1000 );
     2268        stat->blocksToClient      = tr_historyGet( peer->blocksSentToClient,  now, CANCEL_HISTORY_SEC*1000 );
     2269        stat->cancelsToPeer       = tr_historyGet( peer->cancelsSentToPeer,   now, CANCEL_HISTORY_SEC*1000 );
     2270        stat->cancelsToClient     = tr_historyGet( peer->cancelsSentToClient, now, CANCEL_HISTORY_SEC*1000 );
    22752271
    22762272        stat->pendingReqsToPeer   = peer->pendingReqsToPeer;
  • trunk/libtransmission/peer-msgs.c

    r10332 r10347  
    14401440            int i;
    14411441            struct peer_request r;
    1442             const uint64_t now_msec = tr_date( );
    14431442            tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.index );
    14441443            tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.offset );
    14451444            tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.length );
    1446             tr_historyAdd( msgs->torrent->blocksSentToClient, now_msec, 1 );
    1447             tr_historyAdd( msgs->peer->cancelsSentToClient, now_msec, 1 );
     1445            tr_historyAdd( msgs->peer->cancelsSentToClient, tr_date( ), 1 );
    14481446            dbgmsg( msgs, "got a Cancel %u:%u->%u", r.index, r.offset, r.length );
    14491447
     
    19271925            else
    19281926            {
    1929                 const uint64_t now_msec = tr_date( );
    19301927                dbgmsg( msgs, "sending block %u:%u->%u", req.index, req.offset, req.length );
    19311928                EVBUFFER_LENGTH(out) += req.length;
     
    19341931                bytesWritten += EVBUFFER_LENGTH( out );
    19351932                msgs->clientSentAnythingAt = now;
    1936                 tr_historyAdd( msgs->torrent->blocksSentToClient, now_msec, 1 );
    1937                 tr_historyAdd( msgs->peer->blocksSentToPeer, now_msec, 1 );
     1933                tr_historyAdd( msgs->peer->blocksSentToPeer, tr_date( ), 1 );
    19381934            }
    19391935
  • trunk/libtransmission/torrent.c

    r10332 r10347  
    611611    static int nextUniqueId = 1;
    612612    tr_session * session = tr_ctorGetSession( ctor );
    613     const int sec = TORRENT_DOWNLOAD_CONGESTION_HISTORY_SEC;
    614613
    615614    assert( session != NULL );
     
    620619    tor->uniqueId = nextUniqueId++;
    621620    tor->magicNumber = TORRENT_MAGIC_NUMBER;
    622 
    623     tor->blocksSentToClient  = tr_historyNew( sec, 1 );
    624     tor->blocksSentToPeer    = tr_historyNew( sec, 1 );
    625     tor->cancelsSentToClient = tr_historyNew( sec, 1 );
    626     tor->cancelsSentToPeer   = tr_historyNew( sec, 1 );
    627621
    628622    tr_sha1( tor->obfuscatedHash, "req2", 4,
     
    12971291
    12981292    tr_bitfieldDestruct( &tor->checkedPieces );
    1299 
    1300     tr_historyFree( tor->blocksSentToClient  );
    1301     tr_historyFree( tor->blocksSentToPeer    );
    1302     tr_historyFree( tor->cancelsSentToClient );
    1303     tr_historyFree( tor->cancelsSentToPeer   );
    13041293
    13051294    tr_free( tor->downloadDir );
  • trunk/libtransmission/torrent.h

    r10332 r10347  
    1919
    2020#include "completion.h" /* tr_completion */
    21 #include "history.h" /* tr_recentHistory */
    2221#include "session.h" /* tr_sessionLock(), tr_sessionUnlock() */
    2322#include "utils.h" /* TR_GNUC_PRINTF */
     
    177176    const char * currentDir;
    178177
    179     tr_recentHistory       * blocksSentToClient;
    180     tr_recentHistory       * blocksSentToPeer;
    181 
    182     tr_recentHistory       * cancelsSentToClient;
    183     tr_recentHistory       * cancelsSentToPeer;
    184 
    185178    /* How many bytes we ask for per request */
    186179    uint32_t                   blockSize;
     
    351344enum
    352345{
    353     TORRENT_DOWNLOAD_CONGESTION_HISTORY_SEC = 120,
    354 
    355346    TORRENT_MAGIC_NUMBER = 95549
    356347};
Note: See TracChangeset for help on using the changeset viewer.