Changeset 10141


Ignore:
Timestamp:
Feb 8, 2010, 4:47:30 PM (12 years ago)
Author:
charles
Message:

(trunk) per-tier up/down/corrupt byte counts for announcing to trackers

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r10137 r10141  
    44dnl         "0" for stable, supported releases
    55dnl these should be the only two lines you need to change
    6 m4_define([user_agent_prefix],[1.83])
    7 m4_define([peer_id_prefix],[-TR1830-])
     6m4_define([user_agent_prefix],[1.83w])
     7m4_define([peer_id_prefix],[-TR1832-])
    88
    99AC_INIT([transmission],
  • trunk/libtransmission/announcer.c

    r10099 r10141  
    348348typedef struct
    349349{
     350    /* number of up/down/corrupt bytes since the last time we sent an
     351     * "event=stopped" message that was acknowledged by the tracker */
     352    uint64_t byteCounts[3];
     353
    350354    tr_ptrArray trackers; /* tr_tracker_item */
    351355    tr_tracker_item * currentTracker;
     
    669673                              torrent->peer_id,
    670674                              (int)tr_sessionGetPeerPort( announcer->session ),
    671                               torrent->uploadedCur,
    672                               torrent->downloadedCur,
     675                              tier->byteCounts[TR_ANN_UP],
     676                              tier->byteCounts[TR_ANN_DOWN],
    673677                              tr_cpLeftUntilComplete( &torrent->completion ),
    674678                              numwant,
    675679                              tracker->key_param );
    676680
    677     if( torrent->corruptCur )
    678         evbuffer_add_printf( buf, "&corrupt=%" PRIu64, torrent->corruptCur );
     681    if( tier->byteCounts[TR_ANN_CORRUPT] )
     682        evbuffer_add_printf( buf, "&corrupt=%" PRIu64, tier->byteCounts[TR_ANN_CORRUPT] );
    679683
    680684    str = eventName;
     
    920924}
    921925
     926/***
     927****
     928***/
     929
     930void
     931tr_announcerAddBytes( tr_torrent * tor, int type, uint32_t byteCount )
     932{
     933    int i, n;
     934    tr_torrent_tiers * tiers;
     935
     936    assert( tr_isTorrent( tor ) );
     937    assert( type==TR_ANN_UP || type==TR_ANN_DOWN || type==TR_ANN_CORRUPT );
     938
     939    tiers = tor->tiers;
     940    n = tr_ptrArraySize( &tiers->tiers );
     941    for( i=0; i<n; ++i )
     942    {
     943        tr_tier * tier = tr_ptrArrayNth( &tiers->tiers, i );
     944        tier->byteCounts[ type ] += byteCount;
     945    }
     946}
     947
     948void
     949tr_announcerSubtractBytes( tr_torrent * tor, int type, uint32_t byteCount )
     950{
     951    int i, n;
     952    tr_torrent_tiers * tiers;
     953
     954    assert( tr_isTorrent( tor ) );
     955    assert( type==TR_ANN_UP || type==TR_ANN_DOWN || type==TR_ANN_CORRUPT );
     956
     957    tiers = tor->tiers;
     958    n = tr_ptrArraySize( &tiers->tiers );
     959    for( i=0; i<n; ++i )
     960    {
     961        tr_tier * tier = tr_ptrArrayNth( &tiers->tiers, i );
     962        uint64_t * setme = &tier->byteCounts[type];
     963        *setme -= MIN( *setme, byteCount );
     964    }
     965}
     966
     967/***
     968****
     969***/
    922970
    923971void
     
    937985            {
    938986                struct stop_message * s = tr_new0( struct stop_message, 1 );
    939                 s->up = tor->uploadedCur;
    940                 s->down = tor->downloadedCur;
     987                s->up = tier->byteCounts[TR_ANN_UP];
     988                s->down = tier->byteCounts[TR_ANN_DOWN];
    941989                s->url = createAnnounceURL( announcer, tor, tier, "stopped" );
    942990                s->host = tier->currentTracker->host;
     
    10081056    /* upload comes before download */
    10091057    if( !ret )
    1010         ret = compareTransfer( a->tor->uploadedCur, a->tor->downloadedCur,
    1011                                b->tor->uploadedCur, b->tor->downloadedCur );
     1058        ret = compareTransfer( a->byteCounts[TR_ANN_UP], a->byteCounts[TR_ANN_DOWN],
     1059                               b->byteCounts[TR_ANN_UP], b->byteCounts[TR_ANN_DOWN] );
    10121060
    10131061    /* incomplete comes before complete */
     
    12261274            success = parseAnnounceResponse( tier, response, responseLen, isStopped, &gotScrape );
    12271275            dbgmsg( tier, "success is %d", success );
     1276
     1277            if( isStopped )
     1278            {
     1279                /* now that we've successfully stopped the torrent,
     1280                 * we can reset the up/down/corrupt count we've kept
     1281                 * for this tracker */
     1282                tier->byteCounts[ TR_ANN_UP ] = 0;
     1283                tier->byteCounts[ TR_ANN_DOWN ] = 0;
     1284                tier->byteCounts[ TR_ANN_CORRUPT ] = 0;
     1285            }
    12281286        }
    12291287        else if( responseCode )
  • trunk/libtransmission/announcer.h

    r9965 r10141  
    9292void tr_announcerTorrentCompleted( tr_torrent * );
    9393
     94enum { TR_ANN_UP, TR_ANN_DOWN, TR_ANN_CORRUPT };
     95void tr_announcerAddBytes( tr_torrent *, int up_down_or_corrupt, uint32_t byteCount );
     96void tr_announcerSubtractBytes( tr_torrent *, int up_down_or_corrupt, uint32_t byteCount );
     97
    9498time_t tr_announcerNextManualAnnounce( const tr_torrent * );
    9599
  • trunk/libtransmission/peer-mgr.c

    r10088 r10141  
    11851185    tor->corruptCur += byteCount;
    11861186    tor->downloadedCur -= MIN( tor->downloadedCur, byteCount );
     1187
     1188    tr_announcerAddBytes( tor, TR_ANN_CORRUPT, byteCount );
     1189    tr_announcerSubtractBytes( tor, TR_ANN_DOWN, byteCount );
    11871190}
    11881191
     
    12391242{
    12401243    tor->downloadedCur -= MIN( tor->downloadedCur, byteCount );
     1244    tr_announcerSubtractBytes( tor, TR_ANN_DOWN, byteCount );
    12411245}
    12421246
     
    13051309            if( e->wasPieceData ) {
    13061310                tor->uploadedCur += e->length;
     1311                tr_announcerAddBytes( tor, TR_ANN_UP, e->length );
    13071312                tr_torrentSetDirty( tor );
    13081313            }
     
    13591364            if( peer && e->wasPieceData ) {
    13601365                tor->downloadedCur += e->length;
     1366                tr_announcerAddBytes( tor, TR_ANN_DOWN, e->length );
    13611367                tr_torrentSetDirty( tor );
    13621368            }
Note: See TracChangeset for help on using the changeset viewer.