Changeset 8893


Ignore:
Timestamp:
Aug 11, 2009, 9:31:33 PM (12 years ago)
Author:
charles
Message:

(trunk libT) #2211: Behaviour when tracker barfs

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r8888 r8893  
    308308if test "x$enable_nls" = "xyes" ; then
    309309    use_nls=yes
    310     IT_PROG_INTLTOOL([0.40.0],[no-xml])
     310    IT_PROG_INTLTOOL([0.35.0],[no-xml])
    311311    AC_CHECK_HEADERS([libintl.h])
    312312    GETTEXT_PACKAGE=transmission
  • trunk/libtransmission/tracker.c

    r8889 r8893  
    4949
    5050    /* unless the tracker says otherwise, this is the announce interval */
    51     DEFAULT_ANNOUNCE_INTERVAL_SEC = ( 60 * 4 ),
     51    DEFAULT_ANNOUNCE_INTERVAL_SEC = ( 60 * 10 ),
    5252
    5353    /* unless the tracker says otherwise, this is the announce min_interval */
     
    123123
    124124    time_t    lastScrapeTime;
    125     long      lastScrapeResponse;
     125    char      lastScrapeStr[128];
    126126
    127127    time_t    lastAnnounceTime;
    128     long      lastAnnounceResponse;
     128    char      lastAnnounceStr[128];
    129129};
    130130
     
    421421    dbgmsg( t->name, "tracker response: %ld", responseCode );
    422422    tr_ndbg( t->name, "tracker response: %ld", responseCode );
    423     t->lastAnnounceResponse = responseCode;
     423    t->lastAnnounceStr[0] = '\0';
    424424
    425425    if( responseCode == HTTP_OK )
     
    443443            if( tr_bencDictFindStr( &benc, "failure reason", &str ) )
    444444            {
     445                tr_strlcpy( t->lastAnnounceStr, str, sizeof( t->lastAnnounceStr ) );
    445446                publishMessage( t, str, TR_TRACKER_ERROR );
    446447                success = FALSE;
     
    448449
    449450            if( tr_bencDictFindStr( &benc, "warning message", &str ) )
     451            {
     452                tr_strlcpy( t->lastAnnounceStr, str, sizeof( t->lastAnnounceStr ) );
    450453                publishWarning( t, str );
     454            }
    451455
    452456            if( tr_bencDictFindInt( &benc, "interval", &i ) )
     
    505509                publishNewPeersCompact6( t, allAreSeeds, raw, rawlen );
    506510            }
     511
     512            if( !*t->lastAnnounceStr )
     513                tr_strlcpy( t->lastAnnounceStr, _( "Success" ), sizeof( t->lastAnnounceStr ) );
    507514        }
    508515
     
    514521        /* %1$ld - http status code, such as 404
    515522         * %2$s - human-readable explanation of the http status code */
    516         char * buf = tr_strdup_printf( _( "Tracker request failed.  Got HTTP Status Code %1$ld (%2$s)" ),
     523        char * buf = tr_strdup_printf( _( "Announce failed: tracker gave HTTP Response Code %1$ld (%2$s)" ),
    517524                                      responseCode,
    518525                                      tr_webGetResponseStr( responseCode ) );
     526        tr_strlcpy( t->lastAnnounceStr, buf, sizeof( t->lastAnnounceStr ) );
    519527        publishWarning( t, buf );
    520528        tr_free( buf );
     529    }
     530    else
     531    {
     532        tr_strlcpy( t->lastAnnounceStr, _( "Announce failed: tracker did not respond." ), sizeof( t->lastAnnounceStr ) );
    521533    }
    522534
     
    541553           treat this as both a successful announce AND scrape. */
    542554        if( scrapeFields >= 3 ) {
    543             t->lastScrapeResponse = responseCode;
    544555            t->lastScrapeTime = now;
    545556            t->scrapeAt = now + t->scrapeIntervalSec + t->randOffset;
     
    610621    dbgmsg( t->name, "scrape response: %ld\n", responseCode );
    611622    tr_ndbg( t->name, "scrape response: %ld", responseCode );
    612     t->lastScrapeResponse = responseCode;
     623    t->lastScrapeStr[0] = '\0';
    613624
    614625    if( responseCode == HTTP_OK )
     
    678689    {
    679690        const int interval = t->scrapeIntervalSec + t->randOffset;
    680         dbgmsg( t->name, "Request succeeded. Rescraping in %d seconds",
    681                 interval );
    682         tr_ndbg( t->name, "Request succeeded. Rescraping in %d seconds",
    683                  interval );
    684691        t->scrapeAt = time( NULL ) + interval;
     692
     693        tr_strlcpy( t->lastScrapeStr, _( "Success" ), sizeof( t->lastScrapeStr ) );
     694        tr_ndbg( t->name, "Request succeeded. Rescraping in %d seconds", interval );
    685695    }
    686696    else if( 300 <= responseCode && responseCode <= 399 )
    687697    {
    688698        const int interval = 5;
    689         dbgmsg( t->name, "Got a redirect. Retrying in %d seconds", interval );
    690699        t->scrapeAt = time( NULL ) + interval;
     700
     701        tr_snprintf( t->lastScrapeStr, sizeof( t->lastScrapeStr ), "Got a redirect. Retrying in %d seconds", interval );
     702        tr_ndbg( t->name, "%s", t->lastScrapeStr );
    691703    }
    692704    else
    693705    {
    694706        const int interval = t->retryScrapeIntervalSec + t->randOffset;
    695         dbgmsg(
    696             t->name,
    697             "Tracker responded to scrape with %ld. Retrying in %d seconds.",
    698             responseCode,  interval );
    699707        t->retryScrapeIntervalSec *= 2;
    700708        t->scrapeAt = time( NULL ) + interval;
    701     }
     709
     710        /* %1$ld - http status code, such as 404
     711         * %2$s - human-readable explanation of the http status code */
     712        if( !responseCode )
     713            tr_strlcpy( t->lastScrapeStr, _( "Scrape failed: tracker did not respond." ), sizeof( t->lastScrapeStr ) );
     714        else
     715            tr_snprintf( t->lastScrapeStr, sizeof( t->lastScrapeStr ),
     716                         _( "Scrape failed: tracker gave HTTP Response Code %1$ld (%2$s)" ),
     717                         responseCode, tr_webGetResponseStr( responseCode ) );
     718    }
     719
     720    dbgmsg( t->name, "%s", t->lastScrapeStr );
    702721}
    703722
     
    10791098    t->downloaderCount          = -1;
    10801099    t->leecherCount             = -1;
    1081     t->lastAnnounceResponse     = -1;
    1082     t->lastScrapeResponse       = -1;
    10831100    t->manualAnnounceAllowedAt  = ~(time_t)0;
    10841101    t->name                     = tr_strdup( info->name );
     
    12401257    setme->nextAnnounceTime = t->reannounceAt;
    12411258    setme->manualAnnounceTime = t->manualAnnounceAllowedAt;
    1242 
    1243     if( t->lastScrapeResponse == -1 ) /* never been scraped */
    1244         *setme->scrapeResponse = '\0';
    1245     else
    1246         tr_snprintf( setme->scrapeResponse,
    1247                      sizeof( setme->scrapeResponse ),
    1248                      "%s (%ld)",
    1249                      tr_webGetResponseStr( t->lastScrapeResponse ),
    1250                      t->lastScrapeResponse );
    1251 
    1252     if( t->lastAnnounceResponse == -1 ) /* never been announced */
    1253         *setme->announceResponse = '\0';
    1254     else
    1255         tr_snprintf( setme->announceResponse,
    1256                      sizeof( setme->announceResponse ),
    1257                      "%s (%ld)",
    1258                      tr_webGetResponseStr( t->lastAnnounceResponse ),
    1259                      t->lastAnnounceResponse );
    1260 }
    1261 
     1259    tr_strlcpy( setme->scrapeResponse, t->lastScrapeStr, sizeof( setme->scrapeResponse ) );
     1260    tr_strlcpy( setme->announceResponse, t->lastAnnounceStr, sizeof( setme->announceResponse ) );
     1261}
  • trunk/libtransmission/transmission.h

    r8871 r8893  
    15301530    uint64_t    haveUnchecked;
    15311531
    1532     /** This is the unmodified string returned by the tracker in response
    1533         to the torrent's most recent scrape request.  If no request was
    1534         sent or there was no response, this string is empty. */
    1535     char    scrapeResponse[64];
    1536 
    1537     /** The unmodified string returned by the tracker in response
    1538         to the torrent's most recent scrape request.  If no request was
    1539         sent or there was no response, this string is empty. */
    1540     char    announceResponse[64];
     1532    /**
     1533     * This is a human-readable string with the last scrape's results.
     1534     * 1. If an http error occurred, the response code and description is given.
     1535     * 2. If the tracker gave an error or warning messae, that is given.
     1536     * 3. If everything went fine, "Success" is given.
     1537     */
     1538    char    scrapeResponse[128];
     1539
     1540    /** This is a human-readable string with the last announce's results.
     1541        Its contents have the same form as scrapeResponse. */
     1542    char    announceResponse[128];
    15411543
    15421544    /** Time the most recent scrape request was sent,
Note: See TracChangeset for help on using the changeset viewer.