Changeset 3167


Ignore:
Timestamp:
Sep 25, 2007, 6:39:58 PM (14 years ago)
Author:
charles
Message:

better handling of tracker error messages.

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r3155 r3167  
    172172            break;
    173173
     174        case TR_TRACKER_ERROR_CLEAR:
     175            tor->error = 0;
     176            tor->errorString[0] = '\0';
     177            break;
     178
    174179        case TR_TRACKER_STOPPED:
    175180            //assert( tor->runStatus == TR_RUN_STOPPING );
  • trunk/libtransmission/tracker.c

    r3119 r3167  
    199199    tr_publisherPublish( tor->publisher, tor, &event );
    200200}
     201
     202static void
     203publishErrorClear( Torrent * tor )
     204{
     205    publishMessage( tor, NULL, TR_TRACKER_ERROR_CLEAR );
     206}
     207
    201208static void
    202209publishErrorMessage( Torrent * tor, const char * msg )
     
    204211    publishMessage( tor, msg, TR_TRACKER_ERROR );
    205212}
     213
    206214static void
    207215publishWarningMessage( Torrent * tor, const char * msg )
     
    264272
    265273    if( !t->scrapeTimer )
    266          t->scrapeTimer = tr_timerNew( t->handle, onTrackerScrapeNow, t, 1000 );
     274         t->scrapeTimer = tr_timerNew( t->handle, onTrackerScrapeNow, t, 5000 );
    267275}
    268276
     
    451459{
    452460    char * ret = NULL;
    453     int used = 0, max = 0;
    454461    int moveToNextAddress = FALSE;
    455462
    456463    if( !req )
    457464    {
    458         tr_sprintf( &ret, &used, &max,
    459                     "Connecting to %s got a NULL response",
    460                     t->addresses[t->addressIndex].announce );
     465        ret = tr_strdup( "No response from tracker -- will keep trying." );
    461466        tr_inf( ret );
    462467
     
    502507    else
    503508    {
    504         tr_sprintf( &ret, &used, &max,
    505                     "Error connecting: %s",
    506                     t->addresses[t->addressIndex].announce,
    507                     req->response_code_line );
    508 
     509        ret = tr_strdup( "No response from tracker -- will keep trying." );
    509510        moveToNextAddress = TRUE;
    510511    }
     
    605606                }
    606607
     608                publishErrorClear( tor );
     609
    607610                if(( tmp = tr_bencDictFind( tordict, "complete" )))
    608611                    tor->seeders = tmp->val.i;
     
    656659    }
    657660
    658     if (( errmsg = updateAddresses( t, req ) )) {
     661    if (( errmsg = updateAddresses( t, req ) ))
    659662        tr_err( errmsg );
    660         tr_free( errmsg );
    661     }
    662663
    663664    if( !tr_ptrArrayEmpty( t->scraping ) )
     
    666667        Torrent ** torrents =
    667668            (Torrent**) tr_ptrArrayPeek( t->scraping, &n );
    668         for( i=0; i<n; ++i )
     669        for( i=0; i<n; ++i ) {
     670            if( errmsg != NULL )
     671                publishErrorMessage( torrents[i], errmsg );
    669672            onTorrentScrapeNow( torrents[i] );
     673        }
    670674        tr_ptrArrayClear( t->scraping );
    671675    }
     676    tr_free( errmsg );
    672677
    673678    if( !tr_ptrArrayEmpty( t->scrapeQueue ) )
     
    863868        const int bencLoaded = !parseBencResponse( req, &benc );
    864869
     870        publishErrorClear( tor );
     871
    865872        if( bencLoaded && benc.type==TYPE_DICT )
    866873        {
  • trunk/libtransmission/tracker.h

    r3105 r3167  
    3434    TR_TRACKER_WARNING,
    3535    TR_TRACKER_ERROR,
     36    TR_TRACKER_ERROR_CLEAR,
    3637    TR_TRACKER_PEERS,
    3738    TR_TRACKER_STOPPED
Note: See TracChangeset for help on using the changeset viewer.