Changeset 11583


Ignore:
Timestamp:
Dec 23, 2010, 7:32:59 PM (11 years ago)
Author:
charles
Message:

(trunk) #1408 "total downloading and seeding time per torrent" -- add patch to track how long a torrent has been seeding or downloading

Location:
trunk/libtransmission
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/resume.c

    r11506 r11583  
    5252#define KEY_USE_GLOBAL_SPEED_LIMIT "use-global-speed-limit"
    5353#define KEY_USE_SPEED_LIMIT        "use-speed-limit"
     54#define KEY_TIME_SEEDING           "seeding-time-seconds"
     55#define KEY_TIME_DOWNLOADING       "downloading-time-seconds"
    5456#define KEY_SPEEDLIMIT_DOWN_SPEED  "down-speed"
    5557#define KEY_SPEEDLIMIT_DOWN_MODE   "down-mode"
     
    506508
    507509    tr_bencInitDict( &top, 50 ); /* arbitrary "big enough" number */
     510    tr_bencDictAddInt( &top, KEY_TIME_SEEDING, tor->secondsSeeding );
     511    tr_bencDictAddInt( &top, KEY_TIME_DOWNLOADING, tor->secondsDownloading );
    508512    tr_bencDictAddInt( &top, KEY_ACTIVITY_DATE, tor->activityDate );
    509513    tr_bencDictAddInt( &top, KEY_ADDED_DATE, tor->addedDate );
     
    637641    }
    638642
     643    if( ( fieldsToLoad & TR_FR_TIME_SEEDING )
     644      && tr_bencDictFindInt( &top, KEY_TIME_SEEDING, &i ) )
     645    {
     646        tor->secondsSeeding = i;
     647        fieldsLoaded |= TR_FR_TIME_SEEDING;
     648    }
     649
     650    if( ( fieldsToLoad & TR_FR_TIME_DOWNLOADING )
     651      && tr_bencDictFindInt( &top, KEY_TIME_DOWNLOADING, &i ) )
     652    {
     653        tor->secondsDownloading = i;
     654        fieldsLoaded |= TR_FR_TIME_DOWNLOADING;
     655    }
     656
    639657    if( ( fieldsToLoad & TR_FR_BANDWIDTH_PRIORITY )
    640658      && tr_bencDictFindInt( &top, KEY_BANDWIDTH_PRIORITY, &i )
  • trunk/libtransmission/resume.h

    r11044 r11583  
    3737    TR_FR_ACTIVITY_DATE       = ( 1 << 15 ),
    3838    TR_FR_RATIOLIMIT          = ( 1 << 16 ),
    39     TR_FR_IDLELIMIT           = ( 1 << 17 )
     39    TR_FR_IDLELIMIT           = ( 1 << 17 ),
     40    TR_FR_TIME_SEEDING        = ( 1 << 18 ),
     41    TR_FR_TIME_DOWNLOADING    = ( 1 << 19 )
    4042};
    4143
  • trunk/libtransmission/rpcimpl.c

    r11548 r11583  
    595595    else if( tr_streq( key, keylen, "status" ) )
    596596        tr_bencDictAddInt( d, key, st->activity );
     597    else if( tr_streq( key, keylen, "secondsDownloading" ) )
     598        tr_bencDictAddInt( d, key, st->secondsDownloading );
     599    else if( tr_streq( key, keylen, "secondsSeeding" ) )
     600        tr_bencDictAddInt( d, key, st->secondsSeeding );
    597601    else if( tr_streq( key, keylen, "trackers" ) )
    598602        addTrackers( inf, tr_bencDictAddList( d, key, inf->trackerCount ) );
  • trunk/libtransmission/session.c

    r11524 r11583  
    547547    const int max = 999999;
    548548    struct timeval tv;
     549    tr_torrent * tor = NULL;
    549550    tr_session * session = vsession;
    550551
    551552    assert( tr_isSession( session ) );
    552553    assert( session->nowTimer != NULL );
     554
     555    /**
     556    ***  tr_session things to do once per second
     557    **/
     558
     559    tr_timeUpdate( time( NULL ) );
     560
     561    if( session->turtle.isClockEnabled )
     562        turtleCheckClock( session, &session->turtle );
     563
     564    while(( tor = tr_torrentNext( session, tor ))) {
     565        if( tor->isRunning ) {
     566            if( tr_torrentIsSeed( tor ) )
     567                ++tor->secondsSeeding;
     568            else
     569                ++tor->secondsDownloading;
     570        }
     571    }
     572
     573    /**
     574    ***  Set the timer
     575    **/
    553576
    554577    /* schedule the next timer for right after the next second begins */
     
    559582    tr_timerAdd( session->nowTimer, 0, usec );
    560583    /* fprintf( stderr, "time %zu sec, %zu microsec\n", (size_t)tr_time(), (size_t)tv.tv_usec ); */
    561 
    562     /* tr_session things to do once per second */
    563     tr_timeUpdate( tv.tv_sec );
    564     if( session->turtle.isClockEnabled )
    565         turtleCheckClock( session, &session->turtle );
    566584}
    567585
  • trunk/libtransmission/torrent.c

    r11574 r11583  
    11611161    s->metadataPercentComplete = tr_torrentGetMetadataPercent( tor );
    11621162
    1163     s->percentDone      = tr_cpPercentDone  ( &tor->completion );
    1164     s->leftUntilDone    = tr_cpLeftUntilDone( &tor->completion );
    1165     s->sizeWhenDone     = tr_cpSizeWhenDone ( &tor->completion );
    1166     s->recheckProgress  = s->activity == TR_STATUS_CHECK ? getVerifyProgress( tor ) : 0;
    1167     s->activityDate     = tor->activityDate;
    1168     s->addedDate        = tor->addedDate;
    1169     s->doneDate         = tor->doneDate;
    1170     s->startDate        = tor->startDate;
     1163    s->percentDone         = tr_cpPercentDone  ( &tor->completion );
     1164    s->leftUntilDone       = tr_cpLeftUntilDone( &tor->completion );
     1165    s->sizeWhenDone        = tr_cpSizeWhenDone ( &tor->completion );
     1166    s->recheckProgress     = s->activity == TR_STATUS_CHECK ? getVerifyProgress( tor ) : 0;
     1167    s->activityDate        = tor->activityDate;
     1168    s->addedDate           = tor->addedDate;
     1169    s->doneDate            = tor->doneDate;
     1170    s->startDate           = tor->startDate;
     1171    s->secondsSeeding      = tor->secondsSeeding;
     1172    s->secondsDownloading  = tor->secondsDownloading;
    11711173
    11721174    if ((s->activity == TR_STATUS_DOWNLOAD || s->activity == TR_STATUS_SEED) && s->startDate != 0)
  • trunk/libtransmission/torrent.h

    r11522 r11583  
    206206    time_t                     startDate;
    207207    time_t                     anyDate;
     208
     209    time_t                     secondsDownloading;
     210    time_t                     secondsSeeding;
    208211
    209212    tr_torrent_metadata_func  * metadata_func;
  • trunk/libtransmission/transmission.h

    r11540 r11583  
    18741874    int    idleSecs;
    18751875
     1876    /** Cumulative seconds the torrent's ever spent downloading */
     1877    int    secondsDownloading;
     1878
     1879    /** Cumulative seconds the torrent's ever spent seeding */
     1880    int    secondsSeeding;
     1881
    18761882    /** A torrent is considered finished if it has met its seed ratio.
    18771883        As a result, only paused torrents can be finished. */
Note: See TracChangeset for help on using the changeset viewer.