Changeset 10499


Ignore:
Timestamp:
Apr 20, 2010, 4:18:57 PM (11 years ago)
Author:
charles
Message:

(1.9x libT) #3156 "Smarter handling of missing 'complete' and/or 'incomplete' fields in tracker announce responses" -- fix implemented. committing this to 1.9x (rather than backporting later) because trunk's diff is more complicated.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.9x/libtransmission/announcer.c

    r10288 r10499  
    12021202    {
    12031203        int peerCount = 0;
    1204         int incomplete = -1;
    12051204        size_t rawlen;
    12061205        int64_t i;
     
    12461245        }
    12471246
    1248         if( tr_bencDictFindInt( &benc, "complete", &i ) )
    1249         {
     1247        if( !tr_bencDictFindInt( &benc, "complete", &i ) )
     1248            tier->currentTracker->seederCount = 0;
     1249        else {
    12501250            ++scrapeFields;
    12511251            tier->currentTracker->seederCount = i;
    12521252        }
    12531253
    1254         if( tr_bencDictFindInt( &benc, "incomplete", &i ) )
    1255         {
     1254        if( !tr_bencDictFindInt( &benc, "incomplete", &i ) )
     1255            tier->currentTracker->leecherCount = 0;
     1256        else {
    12561257            ++scrapeFields;
    1257             tier->currentTracker->leecherCount = incomplete = i;
     1258            tier->currentTracker->leecherCount = i;
    12581259        }
    12591260
     
    12671268        {
    12681269            /* "compact" extension */
    1269             const int allAreSeeds = incomplete == 0;
     1270            const tr_bool allAreSeeds = !tier->currentTracker->leecherCount;
    12701271            peerCount += publishNewPeersCompact( tier, allAreSeeds, raw, rawlen );
    12711272            gotPeers = TRUE;
     
    12741275        {
    12751276            /* original version of peers */
    1276             const tr_bool allAreSeeds = incomplete == 0;
     1277            const tr_bool allAreSeeds = !tier->currentTracker->leecherCount;
    12771278            size_t byteCount = 0;
    12781279            uint8_t * array = parseOldPeers( tmp, &byteCount );
     
    12851286        {
    12861287            /* "compact" extension */
    1287             const tr_bool allAreSeeds = incomplete == 0;
     1288            const tr_bool allAreSeeds = !tier->currentTracker->leecherCount;
    12881289            peerCount += publishNewPeersCompact6( tier, allAreSeeds, raw, rawlen );
    12891290            gotPeers = TRUE;
Note: See TracChangeset for help on using the changeset viewer.