Changeset 5748


Ignore:
Timestamp:
May 5, 2008, 7:51:53 PM (14 years ago)
Author:
charles
Message:

when one of the trackers in a multitracker list is successful, bump it to the top of the tier.

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r5747 r5748  
    292292}
    293293
     294int
     295tr_torrentPromoteTracker( tr_torrent * tor, int pos )
     296{
     297    int i;
     298    int tier;
     299
     300    assert( tor != NULL );
     301    assert( 0 <= pos && pos < tor->info.trackerCount );
     302
     303    tier = tor->info.trackers[pos].tier;
     304
     305    /* find the index of the first tracker in that tier */
     306    for( i=0; i<tor->info.trackerCount; ++i )
     307        if( tor->info.trackers[i].tier == tier )
     308            break;
     309
     310    assert( i < tor->info.trackerCount );
     311
     312    /* swap them if they're not the same */
     313    if( i != pos ) {
     314        tr_tracker_info tmp = tor->info.trackers[i];
     315        tor->info.trackers[i] = tor->info.trackers[pos];
     316        tor->info.trackers[pos] = tmp;
     317    }
     318
     319    /* return the new position of the tracker that started out at [pos] */
     320    return i;
     321}
     322
    294323struct RandomTracker
    295324{
  • trunk/libtransmission/torrent.h

    r5611 r5748  
    102102void tr_torrentUncheck             ( tr_torrent * );
    103103
     104int tr_torrentPromoteTracker       ( tr_torrent *, int trackerIndex );
     105
    104106time_t* tr_torrentGetMTimes        ( const tr_torrent *, int * setmeCount );
    105107
  • trunk/libtransmission/tracker.c

    r5738 r5748  
    241241    else if( response_code == HTTP_OK )
    242242    {
    243 #if 0
    244 /* FIXME */
    245243        /* multitracker spec: "if a connection with a tracker is
    246244           successful, it will be moved to the front of the tier." */
    247         const int i = t->addressIndex;
    248         const int j = t->tierFronts[i];
    249         const tr_tracker_info swap = t->addresses[i];
    250         t->addresses[i] = t->addresses[j];
    251         t->addresses[j] = swap;
    252 #endif
     245        t->trackerIndex = tr_torrentPromoteTracker( torrent, t->trackerIndex );
    253246    }
    254247    else
Note: See TracChangeset for help on using the changeset viewer.