1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-31 11:23:40 +00:00

(trunk) add a new field to distinguish from error messages returned from the tracker, and announce timeouts, so that they can be displayed differently

This commit is contained in:
Charles Kerr 2010-02-05 05:16:18 +00:00
parent 8b3fb8a5e8
commit 74e3484e75
6 changed files with 24 additions and 12 deletions

View file

@ -1324,6 +1324,7 @@ printDetails( tr_benc * top )
int64_t lastAnnounceStartTime;
tr_bool lastAnnounceSucceeded;
int64_t lastAnnounceTime;
tr_bool lastAnnounceTimedOut;
const char * lastScrapeResult;
tr_bool lastScrapeSucceeded;
int64_t lastScrapeStartTime;
@ -1348,6 +1349,7 @@ printDetails( tr_benc * top )
tr_bencDictFindInt ( t, "lastAnnounceStartTime", &lastAnnounceStartTime ) &&
tr_bencDictFindBool( t, "lastAnnounceSucceeded", &lastAnnounceSucceeded ) &&
tr_bencDictFindInt ( t, "lastAnnounceTime", &lastAnnounceTime ) &&
tr_bencDictFindBool( t, "lastAnnounceTimedOut", &lastAnnounceTimedOut ) &&
tr_bencDictFindStr ( t, "lastScrapeResult", &lastScrapeResult ) &&
tr_bencDictFindInt ( t, "lastScrapeStartTime", &lastScrapeStartTime ) &&
tr_bencDictFindBool( t, "lastScrapeSucceeded", &lastScrapeSucceeded ) &&
@ -1375,6 +1377,8 @@ printDetails( tr_benc * top )
if( lastAnnounceSucceeded )
printf( " Got a list of %'d peers %s ago\n",
(int)lastAnnouncePeerCount, buf );
else if( lastAnnounceTimedOut )
printf( " Peer list request timed out; will retry\n" );
else
printf( " Got an error \"%s\" %s ago\n",
lastAnnounceResult, buf );

View file

@ -267,6 +267,7 @@
| lastAnnounceStartTime | number | tr_tracker_stat
| lastAnnounceSucceeded | boolean | tr_tracker_stat
| lastAnnounceTime | number | tr_tracker_stat
| lastAnnounceTimedOut | boolean | tr_tracker_stat
| lastScrapeResult | string | tr_tracker_stat
| lastScrapeStartTime | number | tr_tracker_stat
| lastScrapeSucceeded | boolean | tr_tracker_stat
@ -580,3 +581,4 @@
| | yes | session-get | new arg "rename-partial-files"
| | yes | session-get | new arg "config-dir"
| | yes | torrent-add | new arg "bandwidthPriority"
| | yes | torrent-get | new trackerStats arg "lastAnnounceTimedOut"

View file

@ -1670,6 +1670,8 @@ buildTrackerSummary( const char * key, const tr_tracker_stat * st, gboolean show
GString * gstr = g_string_new( NULL );
const char * err_markup_begin = "<span color=\"red\">";
const char * err_markup_end = "</span>";
const char * timeout_markup_begin = "<span color=\"#224466\">";
const char * timeout_markup_end = "</span>";
const char * success_markup_begin = "<span color=\"#008B00\">";
const char * success_markup_end = "</span>";
@ -1696,13 +1698,15 @@ buildTrackerSummary( const char * key, const tr_tracker_stat * st, gboolean show
g_string_append_c( gstr, '\n' );
tr_strltime_rounded( timebuf, now - st->lastAnnounceTime, sizeof( timebuf ) );
if( st->lastAnnounceSucceeded )
g_string_append_printf( gstr, _( "Got a list of %s%'d peers%s %s ago" ),
g_string_append_printf( gstr, _( "Got a list of %1$s%2$'d peers%3$s %4$s ago" ),
success_markup_begin, st->lastAnnouncePeerCount, success_markup_end,
timebuf );
else if( st->lastAnnounceTimedOut )
g_string_append_printf( gstr, _( "Peer list request %1$stimed out%2$s %3$s ago; will retry" ),
timeout_markup_begin, timeout_markup_end, timebuf );
else
g_string_append_printf( gstr, _( "Got an error %s\"%s\"%s %s ago" ),
err_markup_begin, st->lastAnnounceResult, err_markup_end,
timebuf );
g_string_append_printf( gstr, _( "Got an error %1$s\"%2$s\"%3$s %4$s ago" ),
err_markup_begin, st->lastAnnounceResult, err_markup_end, timebuf );
}
switch( st->announceState )

View file

@ -39,7 +39,7 @@ if( tr_deepLoggingIsActive( ) ) do { \
enum
{
/* unless the tracker says otherwise, rescrape this frequently */
DEFAULT_SCRAPE_INTERVAL_SEC = ( 60 * 15 ),
DEFAULT_SCRAPE_INTERVAL_SEC = ( 60 * 30 ),
/* unless the tracker says otherwise, this is the announce interval */
DEFAULT_ANNOUNCE_INTERVAL_SEC = ( 60 * 10 ),
@ -358,6 +358,7 @@ typedef struct
time_t lastAnnounceStartTime;
tr_bool lastScrapeSucceeded;
tr_bool lastAnnounceSucceeded;
tr_bool lastAnnounceTimedOut;
time_t scrapeAt;
time_t manualAnnounceAllowedAt;
@ -1324,6 +1325,7 @@ onAnnounceDone( tr_session * session,
}
tier->lastAnnounceSucceeded = success;
tier->lastAnnounceTimedOut = responseCode == 0;
if( success )
{
@ -1434,12 +1436,7 @@ parseScrapeResponse( tr_tier * tier,
if( tr_bencDictFindDict( val, "flags", &flags ) )
if( ( tr_bencDictFindInt( flags, "min_request_interval", &intVal ) ) )
tier->scrapeIntervalSec = intVal;
/* as per ticket #1045, safeguard against trackers returning
* a very low min_request_interval... */
if( tier->scrapeIntervalSec < DEFAULT_SCRAPE_INTERVAL_SEC )
tier->scrapeIntervalSec = DEFAULT_SCRAPE_INTERVAL_SEC;
tier->scrapeIntervalSec = MAX( DEFAULT_SCRAPE_INTERVAL_SEC, (int)intVal );
tr_tordbg( tier->tor,
"Scrape successful. Rescraping in %d seconds.",
@ -1797,6 +1794,7 @@ tr_announcerStats( const tr_torrent * torrent,
st->lastAnnounceTime = tier->lastAnnounceTime;
tr_strlcpy( st->lastAnnounceResult, tier->lastAnnounceStr, sizeof( st->lastAnnounceResult ) );
st->lastAnnounceSucceeded = tier->lastAnnounceSucceeded;
st->lastAnnounceTimedOut = tier->lastAnnounceTimedOut;
st->lastAnnouncePeerCount = tier->lastAnnouncePeerCount;
}

View file

@ -375,7 +375,7 @@ addTrackerStats( const tr_tracker_stat * st, int n, tr_benc * list )
for( i=0; i<n; ++i )
{
const tr_tracker_stat * s = &st[i];
tr_benc * d = tr_bencListAddDict( list, 23 );
tr_benc * d = tr_bencListAddDict( list, 24 );
tr_bencDictAddStr ( d, "announce", s->announce );
tr_bencDictAddInt ( d, "announceState", s->announceState );
tr_bencDictAddInt ( d, "downloadCount", s->downloadCount );
@ -389,6 +389,7 @@ addTrackerStats( const tr_tracker_stat * st, int n, tr_benc * list )
tr_bencDictAddInt ( d, "lastAnnounceStartTime", s->lastAnnounceStartTime );
tr_bencDictAddBool( d, "lastAnnounceSucceeded", s->lastAnnounceSucceeded );
tr_bencDictAddInt ( d, "lastAnnounceTime", s->lastAnnounceTime );
tr_bencDictAddBool( d, "lastAnnounceTimedOut", s->lastAnnounceTimedOut );
tr_bencDictAddStr ( d, "lastScrapeResult", s->lastScrapeResult );
tr_bencDictAddInt ( d, "lastScrapeStartTime", s->lastScrapeStartTime );
tr_bencDictAddBool( d, "lastScrapeSucceeded", s->lastScrapeSucceeded );

View file

@ -1441,6 +1441,9 @@ typedef struct
if "hasAnnounced" is false, this field is undefined */
tr_bool lastAnnounceSucceeded;
/* whether or not the last announce timed out. */
tr_bool lastAnnounceTimedOut;
/* when the last announce was completed.
if "hasAnnounced" is false, this field is undefined */
time_t lastAnnounceTime;