Changeset 4066


Ignore:
Timestamp:
Dec 5, 2007, 2:09:12 AM (14 years ago)
Author:
charles
Message:

backport r4065 to 0.9x

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.9x/libtransmission/tracker.c

    r4037 r4066  
    382382}
    383383
    384 static void
    385 onTrackerResponse( struct evhttp_request * req, void * torrent_hash )
     384static void onReqDone( tr_handle * handle );
     385
     386static void
     387onTrackerResponse( struct evhttp_request * req, void * vhash )
    386388{
    387389    const char * warning;
    388     tr_tracker * t;
    389390    int responseCode;
    390 
    391     t = findTrackerFromHash( torrent_hash );
     391    struct torrent_hash * torrent_hash = (struct torrent_hash*) vhash;
     392    tr_tracker * t = findTrackerFromHash( torrent_hash );
     393
     394    onReqDone( torrent_hash->handle );
    392395    tr_free( torrent_hash );
     396
    393397    if( t == NULL ) /* tracker has been closed */
    394398        return;
     
    542546    const char * warning;
    543547    time_t nextScrapeSec = 60;
    544     tr_tracker * t = findTrackerFromHash( vhash );
     548    struct torrent_hash * torrent_hash = (struct torrent_hash*) vhash;
     549    tr_tracker * t = findTrackerFromHash( torrent_hash );
     550
     551    onReqDone( torrent_hash->handle );
     552    tr_free( torrent_hash );
    545553
    546554    dbgmsg( t, "Got scrape response for '%s': %s (%d)", (t ? t->name : "(null)"), (req ? req->response_code_line : "(no line)"), (req ? req->response_code : -1) );
    547555
    548     tr_free( vhash );
    549556    if( t == NULL ) /* tracker's been closed... */
    550557        return;
     
    742749    req->req = evhttp_request_new( onScrapeResponse, torrentHashNew( handle, tracker ) );
    743750    req->reqtype = TR_REQ_SCRAPE;
    744     asprintf( &req->uri, "%s%cinfo_hash=%s", a->scrape, strchr(a->scrape,'?')?'&':'?', tracker->escaped );
     751    tr_asprintf( &req->uri, "%s%cinfo_hash=%s", a->scrape, strchr(a->scrape,'?')?'&':'?', tracker->escaped );
    745752    memcpy( req->torrent_hash, tracker->hash, SHA_DIGEST_LENGTH );
    746753    addCommonHeaders( tracker, req->req );
     
    820827    tr_handle * handle = vhandle;
    821828
    822     assert( handle );
    823     assert( handle->tracker );
    824 
    825829    /* libevent references evcon right after calling this function,
    826830       so we can't free it yet... defer it to after this call chain
    827831       has played out */
    828832    tr_timerNew( handle, freeConnection, evcon, 100 );
    829 
    830     --handle->tracker->socketCount;
    831     dbgmsg( NULL, "decrementing socket count to %d", handle->tracker->socketCount );
    832     pulse( handle );
    833833}
    834834
     
    932932}
    933933
     934static void
     935onReqDone( tr_handle * handle )
     936{
     937    pulse( handle );
     938    --handle->tracker->socketCount;
     939    dbgmsg( NULL, "decrementing socket count to %d", handle->tracker->socketCount );
     940}
     941
    934942/***
    935943****  LIFE CYCLE
Note: See TracChangeset for help on using the changeset viewer.