Ignore:
Timestamp:
Oct 2, 2009, 4:54:02 AM (13 years ago)
Author:
charles
Message:

(trunk libT) #2471: added/removed trackers aren't applied until restart

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer.c

    r9229 r9230  
    290290    /* sent as the "key" argument in tracker requests
    291291     * to verify us if our IP address changes.
    292      * This is immutable for the life of the tracker object. */
     292     * This is immutable for the life of the tracker object.
     293     * The +1 is for '\0' */
    293294    char key_param[KEYLEN + 1];
    294295}
     
    394395
    395396    t = tr_new0( tr_tier, 1 );
    396     t->randOffset = tr_cryptoRandInt( 60 );
     397    t->randOffset = tr_cryptoRandInt( tor->uniqueId % 60 );
    397398    t->key = nextKey++;
    398399    t->trackers = TR_PTR_ARRAY_INIT;
     
    474475    tiers->publisher = TR_PUBLISHER_INIT;
    475476    return tiers;
     477}
     478
     479static void
     480tiersClear( tr_torrent_tiers * tiers )
     481{
     482    tr_ptrArrayDestruct( &tiers->tiers, tierFree );
     483    tiers->tiers = TR_PTR_ARRAY_INIT;
    476484}
    477485
     
    702710}
    703711
    704 tr_torrent_tiers *
    705 tr_announcerAddTorrent( tr_announcer * announcer, tr_torrent * tor )
     712static void
     713addTorrentToTier( tr_announcer * announcer, tr_torrent_tiers * tiers, tr_torrent * tor )
    706714{
    707715    int i, n;
    708     tr_torrent_tiers * tiers;
    709716    tr_tracker_info ** infos;
     717    const int trackerCount = tor->info.trackerCount;
     718    const tr_tracker_info  * trackers = tor->info.trackers;
    710719
    711720    /* get the trackers that we support... */
    712     infos = tr_new( tr_tracker_info*, tor->info.trackerCount );
    713     for( i=n=0; i<tor->info.trackerCount; ++i )
    714         if( announceURLIsSupported( tor->info.trackers[i].announce ) )
    715             infos[n++] = &tor->info.trackers[i];
    716 
    717     assert( announcer != NULL );
    718     assert( tr_isTorrent( tor ) );
    719 
    720     tiers = tiersNew( );
     721    infos = tr_new0( tr_tracker_info*, trackerCount );
     722    for( i=n=0; i<trackerCount; ++i )
     723        if( announceURLIsSupported( trackers[i].announce ) )
     724            infos[n++] = &trackers[i];
    721725
    722726    /* build our private table of tiers... */
     
    726730        tr_tier * tier = NULL;
    727731
    728         for( i=0; i<tor->info.trackerCount; ++i )
     732        for( i=0; i<trackerCount; ++i )
    729733        {
    730734            const tr_tracker_info * info = infos[i];
     
    746750
    747751    tr_free( infos );
     752}
     753
     754tr_torrent_tiers *
     755tr_announcerAddTorrent( tr_announcer * announcer, tr_torrent * tor )
     756{
     757    tr_torrent_tiers * tiers;
     758
     759    assert( announcer != NULL );
     760    assert( tr_isTorrent( tor ) );
     761
     762    tiers = tiersNew( );
     763
     764    addTorrentToTier( announcer, tiers, tor );
     765
    748766    return tiers;
     767}
     768
     769void
     770tr_announcerResetTorrent( tr_announcer * announcer, tr_torrent * tor )
     771{
     772    if( tor->tiers != NULL )
     773    {
     774        tiersClear( tor->tiers );
     775
     776        addTorrentToTier( announcer, tor->tiers, tor );
     777    }
    749778}
    750779
Note: See TracChangeset for help on using the changeset viewer.