Ignore:
Timestamp:
Jan 22, 2011, 5:45:54 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) #3933 "announcer.c peer parsing could be simpler" -- fixed.

Remove redundant code by using tr_peerMgrCompactToPex() and tr_peerMgrCompact6ToPex() to parse compact ipv4 and ipv6 peer lists. Simplify the old-style benc peer list parsing and fix a bug that returned too few bytes in the old-style peer array.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r11746 r11750  
    494494        case TR_TRACKER_PEERS:
    495495        {
    496             size_t i, n;
     496            size_t i;
    497497            const int8_t seedProbability = event->seedProbability;
    498498            const tr_bool allAreSeeds = seedProbability == 100;
    499             tr_pex * pex = tr_peerMgrArrayToPex( event->compact,
    500                                                  event->compactLen, &n );
     499
    501500             if( allAreSeeds )
    502                 tr_tordbg( tor, "Got %d seeds from tracker", (int)n );
     501                tr_tordbg( tor, "Got %zu seeds from tracker", event->pexCount );
    503502            else
    504                 tr_tordbg( tor, "Got %d peers from tracker", (int)n );
    505 
    506             for( i = 0; i < n; ++i )
    507                 tr_peerMgrAddPex( tor, TR_PEER_FROM_TRACKER, pex+i, seedProbability );
     503                tr_tordbg( tor, "Got %zu peers from tracker", event->pexCount );
     504
     505            for( i = 0; i < event->pexCount; ++i )
     506                tr_peerMgrAddPex( tor, TR_PEER_FROM_TRACKER, &event->pex[i], seedProbability );
    508507
    509508            if( allAreSeeds && tr_torrentIsPrivate( tor ) )
    510509                tr_peerMgrMarkAllAsSeeds( tor );
    511510
    512             tr_free( pex );
    513511            break;
    514512        }
Note: See TracChangeset for help on using the changeset viewer.