Ticket #1447: tracker.patch

File tracker.patch, 4.5 KB (added by charles, 12 years ago)

possible fix

  • libtransmission/fdlimit.c

     
    3838
    3939#include <sys/types.h>
    4040#include <sys/stat.h>
    41 #ifdef HAVE_GETRLIMIT
    42  #include <sys/time.h> /* getrlimit */
    43  #include <sys/resource.h> /* getrlimit */
    44 #endif
    4541#include <unistd.h>
    4642#include <fcntl.h> /* O_LARGEFILE */
    4743
    tr_fdInit( int globalPeerLimit ) 
    504500    assert( gFd == NULL );
    505501    gFd = tr_new0( struct tr_fd_s, 1 );
    506502    gFd->lock = tr_lockNew( );
    507 
    508 #ifdef HAVE_GETRLIMIT
    509     {
    510         struct rlimit rlim;
    511         getrlimit( RLIMIT_NOFILE, &rlim );
    512         rlim.rlim_cur = MIN( rlim.rlim_max,
    513                             (rlim_t)( globalPeerLimit + NOFILE_BUFFER ) );
    514         setrlimit( RLIMIT_NOFILE, &rlim );
    515         gFd->socketMax = rlim.rlim_cur - NOFILE_BUFFER;
    516         tr_dbg( "setrlimit( RLIMIT_NOFILE, %d )", (int)rlim.rlim_cur );
    517     }
    518 #else
    519503    gFd->socketMax = globalPeerLimit;
    520 #endif
    521504    tr_dbg( "%d usable file descriptors", globalPeerLimit );
    522505
    523506    for( i = 0; i < TR_MAX_OPEN_FILES; ++i )
  • libtransmission/tracker.c

    updateAddresses( tr_tracker * t, 
    257257    {
    258258        /* multitracker spec: "if a connection with a tracker is
    259259           successful, it will be moved to the front of the tier." */
    260         t->trackerIndex = tr_torrentPromoteTracker( torrent,
    261                                                     t->trackerIndex );
     260        t->trackerIndex = tr_torrentPromoteTracker( torrent, t->trackerIndex );
    262261        retry = FALSE; /* we succeeded; no need to retry */
    263262    }
    264263    else if( ++t->trackerIndex >= torrent->info.trackerCount )
    updateAddresses( tr_tracker * t, 
    268267    }
    269268    else
    270269    {
    271         const tr_tracker_info * n = getCurrentAddressFromTorrent( t,
    272                                                                   torrent );
     270        const tr_tracker_info * n = getCurrentAddressFromTorrent( t, torrent );
    273271        tr_ninf( t->name, _( "Trying tracker \"%s\"" ), n->announce );
    274272        retry = TRUE;
    275273    }
    onTrackerResponse( tr_session * session, 
    444442        if( bencLoaded )
    445443            tr_bencFree( &benc );
    446444    }
    447     else
     445    else if( responseCode )
    448446    {
    449447        /* %1$ld - http status code, such as 404
    450448         * %2$s - human-readable explanation of the http status code */
    onTrackerResponse( tr_session * session, 
    457455
    458456    retry = updateAddresses( t, success );
    459457
    460     /**
    461     ***
    462     **/
    463 
    464     if( retry )
     458    if( responseCode && retry )
    465459        responseCode = 300;
    466460
    467     if( 200 <= responseCode && responseCode <= 299 )
     461    if( responseCode == 0 )
     462    {
     463        dbgmsg( t->name, "No response from tracker... retrying in two minutes." );
     464        t->manualAnnounceAllowedAt = ~(time_t)0;
     465        t->reannounceAt = time( NULL ) + t->randOffset + 120;
     466    }
     467    else if( 200 <= responseCode && responseCode <= 299 )
    468468    {
    469469        const int    interval = t->announceIntervalSec + t->randOffset;
    470470        const time_t now = time ( NULL );
    471         dbgmsg( t->name, "request succeeded. reannouncing in %d seconds",
    472                 interval );
     471        dbgmsg( t->name, "request succeeded. reannouncing in %d seconds", interval );
    473472
    474473        /* if the announce response was a superset of the scrape response,
    475474           treat this as both a successful announce AND scrape. */
    onTrackerResponse( tr_session * session, 
    499498        const int interval = 5;
    500499        dbgmsg( t->name, "got a redirect. retrying in %d seconds", interval );
    501500        t->reannounceAt = time( NULL ) + interval;
    502         t->manualAnnounceAllowedAt = time( NULL ) +
    503                                      t->announceMinIntervalSec;
     501        t->manualAnnounceAllowedAt = time( NULL ) + t->announceMinIntervalSec;
    504502    }
    505503    else if( 400 <= responseCode && responseCode <= 499 )
    506504    {
    onTrackerResponse( tr_session * session, 
    524522    else
    525523    {
    526524        /* WTF did we get?? */
    527         dbgmsg(
    528             t->name,
    529             "Invalid response from tracker... retrying in two minutes." );
     525        dbgmsg( t->name, "Invalid response from tracker... retrying in two minutes." );
    530526        t->manualAnnounceAllowedAt = ~(time_t)0;
    531527        t->reannounceAt = time( NULL ) + t->randOffset + 120;
    532528    }