Changeset 12074


Ignore:
Timestamp:
Mar 3, 2011, 6:33:24 PM (12 years ago)
Author:
jordan
Message:

(trunk libT) remove the unused tr_ratecontrol code. switch webseed over to using tr_bandwidth.

Location:
trunk/libtransmission
Files:
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/Makefile.am

    r12003 r12074  
    4747    port-forwarding.c \
    4848    ptrarray.c \
    49     ratecontrol.c \
    5049    resume.c \
    5150    rpcimpl.c \
     
    10099    port-forwarding.h \
    101100    ptrarray.h \
    102     ratecontrol.h \
    103101    resume.h \
    104102    rpcimpl.h \
  • trunk/libtransmission/bandwidth.h

    r11709 r12074  
    1717#ifndef TR_BANDWIDTH_H
    1818#define TR_BANDWIDTH_H
     19
     20#include <assert.h>
    1921
    2022#include "transmission.h"
  • trunk/libtransmission/peer-mgr.c

    r12073 r12074  
    379379}
    380380
    381 static tr_peer*
    382 peerNew( struct peer_atom * atom )
    383 {
    384     tr_peer * peer = tr_new0( tr_peer, 1 );
     381void
     382tr_peerConstruct( tr_peer * peer )
     383{
     384    memset( peer, 0, sizeof( tr_peer ) );
    385385
    386386    peer->have = TR_BITSET_INIT;
    387 
    388     peer->atom = atom;
    389     atom->peer = peer;
    390387
    391388    tr_historyConstruct( &peer->blocksSentToClient,  CANCEL_HISTORY_SEC, ( RECHOKE_PERIOD_MSEC / 1000 ) );
     
    393390    tr_historyConstruct( &peer->cancelsSentToClient, CANCEL_HISTORY_SEC, ( RECHOKE_PERIOD_MSEC / 1000 ) );
    394391    tr_historyConstruct( &peer->cancelsSentToPeer,   CANCEL_HISTORY_SEC, ( REFILL_UPKEEP_PERIOD_MSEC / 1000 ) );
     392}
     393
     394static tr_peer*
     395peerNew( struct peer_atom * atom )
     396{
     397    tr_peer * peer = tr_new( tr_peer, 1 );
     398    tr_peerConstruct( peer );
     399
     400    peer->atom = atom;
     401    atom->peer = peer;
    395402
    396403    return peer;
     
    417424static void peerDeclinedAllRequests( Torrent *, const tr_peer * );
    418425
    419 static void
    420 peerDelete( Torrent * t, tr_peer * peer )
     426void
     427tr_peerDestruct( tr_torrent * tor, tr_peer * peer )
    421428{
    422429    assert( peer != NULL );
    423430
    424     peerDeclinedAllRequests( t, peer );
     431    peerDeclinedAllRequests( tor->torrentPeers, peer );
    425432
    426433    if( peer->msgs != NULL )
    427434        tr_peerMsgsFree( peer->msgs );
    428435
    429     tr_peerIoClear( peer->io );
    430     tr_peerIoUnref( peer->io ); /* balanced by the ref in handshakeDoneCB() */
     436    if( peer->io ) {
     437        tr_peerIoClear( peer->io );
     438        tr_peerIoUnref( peer->io ); /* balanced by the ref in handshakeDoneCB() */
     439    }
    431440
    432441    tr_historyDestruct( &peer->blocksSentToClient  );
     
    439448    tr_free( peer->client );
    440449    peer->atom->peer = NULL;
    441 
     450}
     451
     452static void
     453peerDelete( Torrent * t, tr_peer * peer )
     454{
     455    tr_peerDestruct( t->tor, peer );
    442456    tr_free( peer );
    443457}
     
    24582472    }
    24592473
    2460     if( peer->progress >= 1.0 )
     2474    if( peer->atom && ( peer->progress >= 1.0 ) )
    24612475        atomSetSeed( tor->torrentPeers, peer->atom );
    24622476}
     
    25802594    *setmeWebseedsSendingToUs = countActiveWebseeds( t );
    25812595}
    2582 
    2583 int
    2584 tr_peerMgrGetWebseedSpeed_Bps( const tr_torrent * tor, uint64_t now )
    2585 {
    2586     int i;
    2587     int tmp;
    2588     int ret = 0;
    2589 
    2590     const Torrent * t = tor->torrentPeers;
    2591     const int n = tr_ptrArraySize( &t->webseeds );
    2592     const tr_webseed ** webseeds = (const tr_webseed**) tr_ptrArrayBase( &t->webseeds );
    2593 
    2594     for( i=0; i<n; ++i )
    2595         if( tr_webseedGetSpeed_Bps( webseeds[i], now, &tmp ) )
    2596             ret += tmp;
    2597 
    2598     return ret;
    2599 }
    2600 
    26012596
    26022597double*
  • trunk/libtransmission/peer-mgr.h

    r12022 r12074  
    6969
    7070
    71 struct tr_bandwidth;
    7271struct tr_peerIo;
    7372struct tr_peermsgs;
     
    132131}
    133132tr_peer;
     133
     134void tr_peerConstruct( struct tr_peer * peer );
     135
     136void tr_peerDestruct( tr_torrent * tor, struct tr_peer * peer );
     137
    134138
    135139static inline tr_bool
     
    248252                                          int              * setmeCount );
    249253
    250 int tr_peerMgrGetWebseedSpeed_Bps( const tr_torrent * tor, uint64_t now );
    251 
    252254double* tr_peerMgrWebSpeeds_KBps( const tr_torrent * tor );
    253255
  • trunk/libtransmission/torrent.c

    r12057 r12074  
    11391139    int                     usableSeeds;
    11401140    uint64_t                now;
    1141     double                  d;
    11421141    uint64_t                seedRatioBytesLeft;
    11431142    uint64_t                seedRatioBytesGoal;
     
    11711170
    11721171    now = tr_time_msec( );
    1173     d = tr_peerMgrGetWebseedSpeed_Bps( tor, now );
    11741172    s->rawUploadSpeed_KBps     = toSpeedKBps( tr_bandwidthGetRawSpeed_Bps  ( tor->bandwidth, now, TR_UP ) );
    11751173    s->pieceUploadSpeed_KBps   = toSpeedKBps( tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_UP ) );
    1176     s->rawDownloadSpeed_KBps   = toSpeedKBps( d + tr_bandwidthGetRawSpeed_Bps  ( tor->bandwidth, now, TR_DOWN ) );
    1177     s->pieceDownloadSpeed_KBps = toSpeedKBps( d + tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_DOWN ) );
     1174    s->rawDownloadSpeed_KBps   = toSpeedKBps( tr_bandwidthGetRawSpeed_Bps  ( tor->bandwidth, now, TR_DOWN ) );
     1175    s->pieceDownloadSpeed_KBps = toSpeedKBps( tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_DOWN ) );
    11781176
    11791177    usableSeeds += tor->info.webseedCount;
  • trunk/libtransmission/webseed.c

    r12012 r12074  
    1717
    1818#include "transmission.h"
     19#include "bandwidth.h"
    1920#include "cache.h"
    2021#include "inout.h" /* tr_ioFindFileLocation() */
    2122#include "list.h"
    22 #include "ratecontrol.h"
    2323#include "peer-mgr.h"
    2424#include "torrent.h"
     
    4242{
    4343    tr_peer              parent;
    44     tr_ratecontrol       download_rate;
     44    tr_bandwidth         bandwidth;
    4545    tr_session         * session;
    4646    tr_peer_callback   * callback;
     
    6565webseed_free( struct tr_webseed * w )
    6666{
    67     tr_bitsetDestruct( &w->parent.have );
    68     tr_free( w->parent.client );
    69 
     67    tr_torrent * tor = tr_torrentFindFromId( w->session, w->torrent_id );
     68
     69    /* webseed destruct */
    7070    event_free( w->timer );
    71     tr_rcDestruct( &w->download_rate );
     71    tr_bandwidthDestruct( &w->bandwidth );
    7272    tr_free( w->base_url );
     73
     74    /* parent class destruct */
     75    tr_peerDestruct( tor, &w->parent );
     76
    7377    tr_free( w );
    7478}
     
    126130    if( ( info->n_added > 0 ) && !w->is_stopping )
    127131    {
    128         tr_rcTransferred( &w->download_rate, info->n_added );
     132        tr_bandwidthUsed( &w->bandwidth, TR_DOWN, info->n_added, TRUE, tr_time_msec( ) );
    129133        fire_client_got_data( w, info->n_added );
    130134    }
     
    297301{
    298302    const tr_bool is_active = webseed_has_tasks( w );
    299     *setme_Bps = is_active ? tr_rcRate_Bps( &w->download_rate, now ) : 0;
     303    *setme_Bps = is_active ? tr_bandwidthGetPieceSpeed_Bps( &w->bandwidth, now, TR_DOWN ) : 0;
    300304    return is_active;
    301305}
     
    321325
    322326tr_webseed*
    323 tr_webseedNew( struct tr_torrent * tor,
    324                const char        * url,
    325                tr_peer_callback  * callback,
    326                void              * callback_data )
     327tr_webseedNew( struct tr_torrent  * tor,
     328               const char         * url,
     329               tr_peer_callback   * callback,
     330               void               * callback_data )
    327331{
    328332    tr_webseed * w = tr_new0( tr_webseed, 1 );
    329333    tr_peer * peer = &w->parent;
    330334
     335    /* construct parent class */
     336    tr_peerConstruct( peer );
    331337    peer->peerIsChoked = TRUE;
    332338    peer->clientIsInterested = !tr_torrentIsSeed( tor );
    333     peer->progress = 1.0;
    334339    peer->client = tr_strdup( "webseed" );
    335     peer->have = TR_BITSET_INIT;
    336340    tr_bitsetSetHaveAll( &peer->have );
     341    tr_peerUpdateProgress( tor, peer );
    337342
    338343    w->torrent_id = tr_torrentId( tor );
    339344    w->session = tor->session;
    340 
    341345    w->base_url_len = strlen( url );
    342346    w->base_url = tr_strndup( url, w->base_url_len );
    343347    w->callback = callback;
    344348    w->callback_data = callback_data;
    345     tr_rcConstruct( &w->download_rate );
     349    //tr_rcConstruct( &w->download_rate );
     350    tr_bandwidthConstruct( &w->bandwidth, tor->session, tor->bandwidth );
    346351    w->timer = evtimer_new( w->session->event_base, webseed_timer_func, w );
    347352    tr_timerAddMsec( w->timer, TR_IDLE_TIMER_MSEC );
Note: See TracChangeset for help on using the changeset viewer.