Changeset 1160


Ignore:
Timestamp:
Dec 6, 2006, 8:21:00 PM (16 years ago)
Author:
livings124
Message:

tracker should be set when added rather than when started

Location:
branches/multitracker/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/multitracker/libtransmission/metainfo.c

    r1155 r1160  
    302302    }
    303303   
     304    tr_setTorrentAnnounce( inf, &inf->trackerAnnounceList[0] );
     305   
    304306    free( address );
    305307    free( announce );
  • branches/multitracker/libtransmission/tracker.c

    r1159 r1160  
    6666};
    6767
    68 static void        setAnnounce( tr_tracker_t * tc, tr_announce_list_item_t * announceItem );
    69 static int         announceToScrape( char * announce, char * scrape );
     68static void        setAnnounce      ( tr_tracker_t * tc, tr_announce_list_item_t * announceItem );
    7069static void        failureAnnouncing( tr_tracker_t * tc );
    7170static tr_http_t * getQuery         ( tr_tracker_t * tc );
     
    8281    tc->tor            = tor;
    8382    tc->id             = tor->id;
    84    
    85     setAnnounce( tc, &tor->info.trackerAnnounceList[0] );
    8683
    8784    tc->started        = 1;
     
    103100static void setAnnounce( tr_tracker_t * tc, tr_announce_list_item_t * announceItem )
    104101{
    105     tr_torrent_t * tor = tc->tor;
    106     tr_info_t    * inf = &tor->info;
    107    
    108     tr_lockLock( &tor->lock );
    109    
    110     snprintf( inf->trackerAddress, 256, "%s", announceItem->address );
    111     inf->trackerPort = announceItem->port;
    112     snprintf( inf->trackerAnnounce, MAX_PATH_LENGTH, "%s", announceItem->announce );
    113    
    114     inf->trackerCanScrape = announceToScrape( announceItem->announce, inf->trackerScrape );
     102    tr_lockLock( &tc->tor->lock );
     103   
     104    tr_setTorrentAnnounce( &tc->tor->info, announceItem);
    115105    tc->dateScrape = 0;
    116106   
    117     tr_lockUnlock( &tor->lock );
    118 }
    119 
    120 static int announceToScrape( char * announce, char * scrape )
    121 {   
    122     char * slash, * nextSlash;
    123     int pre, post;
    124    
    125     slash = strchr( announce, '/' );
    126     while( ( nextSlash = strchr( slash + 1, '/' ) ) )
    127     {
    128         slash = nextSlash;
    129     }
    130     slash++;
    131    
    132     if( !strncmp( slash, "announce", 8 ) )
    133     {
    134         pre  = (long) slash - (long) announce;
    135         post = strlen( announce ) - pre - 8;
    136         memcpy( scrape, announce, pre );
    137         sprintf( &scrape[pre], "scrape" );
    138         memcpy( &scrape[pre+6], &announce[pre+8], post );
    139         scrape[pre+6+post] = 0;
    140        
    141         return 1;
    142     }
    143     else
    144     {
    145         return 0;
    146     }
     107    tr_lockUnlock( &tc->tor->lock );
    147108}
    148109
     
    319280           
    320281            setAnnounce( tc, &inf->trackerAnnounceList[tc->announceTier] );
    321            
    322282            tc->shouldChangeAnnounce = 0;
    323283        }
  • branches/multitracker/libtransmission/transmission.c

    r1154 r1160  
    3434static void  acceptLoop( void * );
    3535static void acceptStop( tr_handle_t * h );
     36static int announceToScrape( char * announce, char * scrape );
    3637
    3738/***********************************************************************
     
    543544
    544545    return s;
     546}
     547
     548static int announceToScrape( char * announce, char * scrape )
     549{   
     550    char * slash, * nextSlash;
     551    int pre, post;
     552   
     553    slash = strchr( announce, '/' );
     554    while( ( nextSlash = strchr( slash + 1, '/' ) ) )
     555    {
     556        slash = nextSlash;
     557    }
     558    slash++;
     559   
     560    if( !strncmp( slash, "announce", 8 ) )
     561    {
     562        pre  = (long) slash - (long) announce;
     563        post = strlen( announce ) - pre - 8;
     564        memcpy( scrape, announce, pre );
     565        sprintf( &scrape[pre], "scrape" );
     566        memcpy( &scrape[pre+6], &announce[pre+8], post );
     567        scrape[pre+6+post] = 0;
     568       
     569        return 1;
     570    }
     571    else
     572    {
     573        return 0;
     574    }
     575}
     576
     577/* Must lock torrent before use */
     578void tr_setTorrentAnnounce( tr_info_t * inf, tr_announce_list_item_t * announceItem )
     579{
     580    snprintf( inf->trackerAddress, 256, "%s", announceItem->address );
     581    inf->trackerPort = announceItem->port;
     582    snprintf( inf->trackerAnnounce, MAX_PATH_LENGTH, "%s", announceItem->announce );
     583   
     584    inf->trackerCanScrape = announceToScrape( announceItem->announce, inf->trackerScrape );
    545585}
    546586
  • branches/multitracker/libtransmission/transmission.h

    r1154 r1160  
    260260
    261261/***********************************************************************
     262 * tr_setTorrentAnnounce
     263 ***********************************************************************/
     264void tr_setTorrentAnnounce( tr_info_t * inf, tr_announce_list_item_t * announceItem );
     265
     266/***********************************************************************
    262267 * tr_torrentPeers
    263268 ***********************************************************************/
Note: See TracChangeset for help on using the changeset viewer.