Changeset 2837


Ignore:
Timestamp:
Aug 18, 2007, 8:28:57 AM (15 years ago)
Author:
charles
Message:
  • more work on the tracker... getting closer.
  • oops! make sure autoconf is giving the `0.80+' in the User-Agent header.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r2819 r2837  
    1 AC_INIT([Transmission],[0.80],[http://transmission.m0k.org/trac/newticket])
    2 PEERID_PREFIX="-TR0800-"
    3 USERAGENT_PREFIX="0.80"
     1AC_INIT([Transmission],[0.80+],[http://transmission.m0k.org/trac/newticket])
     2PEERID_PREFIX="-TR080Z-"
     3USERAGENT_PREFIX="0.80+"
    44
    55AC_PREREQ(2.54)
  • trunk/libtransmission/tracker.c

    r2835 r2837  
    5353
    5454/* the length of the 'key' argument passed in tracker requests */
    55 #define TR_KEY_LEN 20
     55#define TR_KEY_LEN 10
    5656
    5757
     
    151151    const Torrent * b = (const Torrent*) vb;
    152152    return memcmp( a->hash, b->hash, SHA_DIGEST_LENGTH );
     153}
     154
     155/***
     156****
     157***/
     158
     159typedef struct
     160{
     161    char * address;
     162    int port;
     163    struct evhttp_connection * evconn;
     164}
     165connection_key_t;
     166
     167static int
     168connectionCompare( const void * va, const void * vb )
     169{
     170    const connection_key_t * a = (const connection_key_t *) va;
     171    const connection_key_t * b = (const connection_key_t *) vb;
     172    int ret = strcmp( a->address, b->address );
     173    if( ret ) return ret;
     174    return a->port - b->port;
     175}
     176
     177static struct evhttp_connection*
     178getConnection( const char * address, int port )
     179{
     180    connection_key_t *val, tmp;
     181
     182    static tr_ptrArray_t * connections = NULL;
     183    if( !connections )
     184        connections = tr_ptrArrayNew( );
     185
     186    tmp.address = (char*) address;
     187    tmp.port = port;
     188    val = tr_ptrArrayFindSorted( connections, &tmp, connectionCompare );
     189
     190    if( !val )
     191    {
     192        val = tr_new( connection_key_t, 1 );
     193        val->address = tr_strdup( address );
     194        val->port = port;
     195        val->evconn = evhttp_connection_new( address, port );
     196        tr_ptrArrayInsertSorted( connections, val, connectionCompare );
     197    }
     198
     199    return val->evconn;
    153200}
    154201
     
    598645            t->multiscrapeMax = numResponses;
    599646    }
     647    else if( !req )
     648    {
     649        int i, n;
     650        Torrent ** torrents = (Torrent**)
     651            tr_ptrArrayPeek( t->scraping, &n );
     652        for( i=0; i<n; ++i ) {
     653            fprintf( stderr, "null req -- torent #%d is %s\n", i, torrents[i]->torrent->info.name );
     654            torrents[i]->scrapeTag = tr_timerNew( t->handle,
     655                                                  onTorrentScrapeNow,
     656                                                  torrents[i], NULL,
     657                                                  t->scrapeIntervalMsec );
     658        }
     659        tr_ptrArrayClear( t->scraping );
     660
     661        t->multiscrapeMax = INT_MAX;
     662    }
    600663
    601664    if (( errmsg = updateAddresses( t, req ) )) {
     
    668731        /* ping the tracker */
    669732        tr_inf( "scrape to %s:%d: %s", address->address, address->port, uri );
    670         evcon = evhttp_connection_new( address->address, address->port );
     733        evcon = getConnection( address->address, address->port );
    671734        assert( evcon != NULL );
    672735        evhttp_connection_set_timeout( evcon, SCRAPE_TIMEOUT_INTERVAL_SEC );
     
    861924    else
    862925    {
    863         tr_inf( "Bad response from tracker '%s' on request '%s'"
     926        tr_inf( "Bad response from tracker '%s' on request '%s' "
    864927                "for torrent '%s'... trying again in 30 seconds",
    865928                tor->tracker->primaryAddress,
     
    905968    tr_timerFree( &tor->reannounceTag );
    906969
    907     evcon = evhttp_connection_new( address->address, address->port );
     970    evcon = getConnection( address->address, address->port );
    908971    if ( !evcon )
    909972        tr_err( "Can't make a connection to %s:%d", address->address, address->port );
     
    917980    }
    918981
    919     tr_free( uri );
    920 
    921982    return FALSE;
    922983}
  • trunk/libtransmission/version.h.in

    r2526 r2837  
    33#define SVN_REVISION          "@SVN_REVISION@"
    44#define SHORT_VERSION_STRING  "@USERAGENT_PREFIX@"
    5 #define LONG_VERSION_STRING   "@USERAGENT_PREFIX@ r(@SVN_REVISION@)"
     5#define LONG_VERSION_STRING   "@USERAGENT_PREFIX@ (r@SVN_REVISION@)"
Note: See TracChangeset for help on using the changeset viewer.