(trunk) #2463: 'Mac Client shows huge "next announce in" timer'

This commit is contained in:
Charles Kerr
2009-10-09 21:30:34 +00:00
parent f92fd55a80
commit f607c7591a
6 changed files with 110 additions and 70 deletions

View File

@@ -1247,8 +1247,6 @@ printDetails( tr_benc * top )
tr_bool hasScraped;
const char * host;
tr_bool isActive;
tr_bool isAnnouncing;
tr_bool isScraping;
int64_t lastAnnouncePeerCount;
const char * lastAnnounceResult;
time_t lastAnnounceStartTime;
@@ -1263,16 +1261,16 @@ printDetails( tr_benc * top )
int64_t nextScrapeTime;
int64_t seederCount;
int64_t tier;
tr_bool willAnnounce;
tr_bool willScrape;
int64_t announceState;
int64_t scrapeState;
if( tr_bencDictFindInt ( t, "downloadCount", &downloadCount ) &&
tr_bencDictFindBool( t, "hasAnnounced", &hasAnnounced ) &&
tr_bencDictFindBool( t, "hasScraped", &hasScraped ) &&
tr_bencDictFindStr ( t, "host", &host ) &&
tr_bencDictFindBool( t, "isActive", &isActive ) &&
tr_bencDictFindBool( t, "isAnnouncing", &isAnnouncing ) &&
tr_bencDictFindBool( t, "isScraping", &isScraping ) &&
tr_bencDictFindInt ( t, "announceState", &announceState ) &&
tr_bencDictFindInt ( t, "scrapeState", &scrapeState ) &&
tr_bencDictFindInt ( t, "lastAnnouncePeerCount", &lastAnnouncePeerCount ) &&
tr_bencDictFindStr ( t, "lastAnnounceResult", &lastAnnounceResult ) &&
tr_bencDictFindInt ( t, "lastAnnounceStartTime", &lastAnnounceStartTime ) &&
@@ -1286,9 +1284,7 @@ printDetails( tr_benc * top )
tr_bencDictFindInt ( t, "nextAnnounceTime", &nextAnnounceTime ) &&
tr_bencDictFindInt ( t, "nextScrapeTime", &nextScrapeTime ) &&
tr_bencDictFindInt ( t, "seederCount", &seederCount ) &&
tr_bencDictFindInt ( t, "tier", &tier ) &&
tr_bencDictFindBool( t, "willAnnounce", &willAnnounce ) &&
tr_bencDictFindBool( t, "willScrape", &willScrape ) )
tr_bencDictFindInt ( t, "tier", &tier ) )
{
const time_t now = time( NULL );
@@ -1310,20 +1306,25 @@ printDetails( tr_benc * top )
lastAnnounceResult, buf );
}
if( isActive && ( isAnnouncing || willAnnounce ) ) {
if( !isAnnouncing ) {
if( isActive ) switch( announceState ) {
case TR_TRACKER_INACTIVE:
printf( " No updates scheduled\n" );
break;
case TR_TRACKER_WAITING:
tr_strltime( buf, nextAnnounceTime - now, sizeof( buf ) );
printf( " Asking for more peers in %s\n", buf );
} else {
break;
case TR_TRACKER_QUEUED:
printf( " Queued to ask for more peers\n" );
break;
case TR_TRACKER_ACTIVE:
tr_strltime( buf, now - lastAnnounceStartTime, sizeof( buf ) );
printf( " Asking for more peers now... %s\n", buf );
}
break;
}
if( !hasAnnounced && !isAnnouncing && !willAnnounce )
printf( " No updates scheduled\n" );
if( isActive && hasScraped ) {
if( isActive && hasScraped )
{
tr_strltime( buf, now - lastScrapeTime, sizeof( buf ) );
if( lastScrapeSucceeded )
printf( " Tracker had %'d seeders and %'d leechers %s ago\n",
@@ -1333,14 +1334,20 @@ printDetails( tr_benc * top )
lastScrapeResult, buf );
}
if( isScraping || willScrape ) {
if( !isScraping ) {
switch( scrapeState ) {
case TR_TRACKER_INACTIVE:
break;
case TR_TRACKER_WAITING:
tr_strltime( buf, nextScrapeTime - now, sizeof( buf ) );
printf( " Asking for peer counts in %s\n", buf );
} else {
break;
case TR_TRACKER_QUEUED:
printf( " Queued to ask for peer counts\n" );
break;
case TR_TRACKER_ACTIVE:
tr_strltime( buf, now - lastScrapeStartTime, sizeof( buf ) );
printf( " Asking for peer counts now... %s\n", buf );
}
break;
}
}
}

View File

@@ -251,13 +251,12 @@
trackerStats | array of objects, each containing: |
+-------------------------+------------+
| announce | string | tr_tracker_stat
| announceState | number | tr_tracker_stat
| downloadCount | number | tr_tracker_stat
| hasAnnounced | boolean | tr_tracker_stat
| hasScraped | boolean | tr_tracker_stat
| host | string | tr_tracker_stat
| isActive | boolean | tr_tracker_stat
| isAnnouncing | boolean | tr_tracker_stat
| isScraping | boolean | tr_tracker_stat
| lastAnnouncePeerCount | number | tr_tracker_stat
| lastAnnounceResult | number | tr_tracker_stat
| lastAnnounceStartTime | number | tr_tracker_stat
@@ -270,10 +269,9 @@
| leecherCount | number | tr_tracker_stat
| nextAnnounceTime | number | tr_tracker_stat
| nextScrapeTime | number | tr_tracker_stat
| scrapeState | number | tr_tracker_stat
| seederCount | number | tr_tracker_stat
| tier | number | tr_tracker_stat
| willAnnounce | boolean | tr_tracker_stat
| willScrape | boolean | tr_tracker_stat
-------------------+-------------------------+------------+
wanted | an array of tr_info.fileCount | tr_info
| 'booleans' true if the corresponding |

View File

@@ -1635,20 +1635,26 @@ buildTrackerSummary( const char * key, const tr_tracker_stat * st, gboolean show
timebuf );
}
if( st->isActive && ( st->isAnnouncing || st->willAnnounce ) ) {
g_string_append_c( gstr, '\n' );
if( !st->isAnnouncing ) {
if( st->isActive ) switch( st->announceState ) {
case TR_TRACKER_INACTIVE:
if( !st->hasAnnounced ) {
g_string_append_c( gstr, '\n' );
g_string_append( gstr, _( "No updates scheduled" ) );
}
break;
case TR_TRACKER_WAITING:
tr_strltime_rounded( timebuf, st->nextAnnounceTime - now, sizeof( timebuf ) );
g_string_append_c( gstr, '\n' );
g_string_append_printf( gstr, _( "Asking for more peers in %s" ), timebuf );
} else {
break;
case TR_TRACKER_QUEUED:
g_string_append_c( gstr, '\n' );
g_string_append( gstr, _( "Queued to ask for more peers" ) );
break;
case TR_TRACKER_ACTIVE:
tr_strltime_rounded( timebuf, now - st->lastAnnounceStartTime, sizeof( timebuf ) );
g_string_append_printf( gstr, _( "Asking for more peers now... <small>%s</small>" ), timebuf );
}
}
if( !st->hasAnnounced && !st->isAnnouncing && !st->willAnnounce ) {
g_string_append_c( gstr, '\n' );
g_string_append( gstr, _( "No updates scheduled" ) );
break;
}
if( st->isActive && showScrape )
@@ -1664,18 +1670,27 @@ buildTrackerSummary( const char * key, const tr_tracker_stat * st, gboolean show
g_string_append_printf( gstr, _( "Got a scrape error \"%s%s%s\" %s ago" ), err_markup_begin, st->lastScrapeResult, err_markup_end, timebuf );
}
if( st->isScraping || st->willScrape ) {
g_string_append_c( gstr, '\n' );
if( !st->isScraping ) {
tr_strltime_rounded( timebuf, st->nextScrapeTime - now, sizeof( timebuf ) );
g_string_append_printf( gstr, _( "Asking for peer counts in %s" ), timebuf );
} else {
switch( st->scrapeState )
{
case TR_TRACKER_INACTIVE:
break;
case TR_TRACKER_WAITING:
g_string_append_c( gstr, '\n' );
tr_strltime_rounded( timebuf, now - st->lastScrapeStartTime, sizeof( timebuf ) );
g_string_append_printf( gstr, _( "Asking for peer counts now... <small>%s</small>" ), timebuf );
}
break;
case TR_TRACKER_QUEUED:
g_string_append_c( gstr, '\n' );
g_string_append( gstr, _( "Queued to ask for peer counts" ) );
break;
case TR_TRACKER_ACTIVE:
g_string_append_c( gstr, '\n' );
tr_strltime_rounded( timebuf, st->nextScrapeTime - now, sizeof( timebuf ) );
g_string_append_printf( gstr, _( "Asking for peer counts in %s" ), timebuf );
break;
}
}
return g_string_free( gstr, FALSE );
}

View File

@@ -1634,6 +1634,7 @@ tr_announcerStats( const tr_torrent * torrent,
int out = 0;
int tierCount;
tr_tracker_stat * ret;
const time_t now = time( NULL );
assert( tr_isTorrent( torrent ) );
@@ -1670,8 +1671,8 @@ tr_announcerStats( const tr_torrent * torrent,
st->lastScrapeTime = 0;
st->lastScrapeSucceeded = FALSE;
st->lastScrapeResult[0] = '\0';
st->isScraping = FALSE;
st->willScrape = FALSE;
st->scrapeState = TR_TRACKER_INACTIVE;
st->announceState = TR_TRACKER_INACTIVE;
st->nextScrapeTime = 0;
st->lastAnnounceStartTime = 0;
st->hasAnnounced = 0;
@@ -1679,8 +1680,6 @@ tr_announcerStats( const tr_torrent * torrent,
st->lastAnnounceResult[0] = '\0';
st->lastAnnounceSucceeded = FALSE;
st->lastAnnouncePeerCount = 0;
st->isAnnouncing = FALSE;
st->willAnnounce = FALSE;
st->nextAnnounceTime = 0;
st->seederCount = 0;
st->leecherCount = 0;
@@ -1694,10 +1693,14 @@ tr_announcerStats( const tr_torrent * torrent,
tr_strlcpy( st->lastScrapeResult, tier->lastScrapeStr, sizeof( st->lastScrapeResult ) );
}
st->isScraping = tier->isScraping;
if(( st->willScrape = !tier->isScraping ))
if( tier->isScraping )
st->scrapeState = TR_TRACKER_ACTIVE;
else if( tierNeedsToScrape( tier, now ) )
st->scrapeState = TR_TRACKER_QUEUED;
else {
st->scrapeState = TR_TRACKER_WAITING;
st->nextScrapeTime = tier->scrapeAt;
}
st->lastAnnounceStartTime = tier->lastAnnounceStartTime;
@@ -1709,10 +1712,16 @@ tr_announcerStats( const tr_torrent * torrent,
}
}
st->isAnnouncing = tier->isAnnouncing;
if(( st->willAnnounce = torrent->isRunning && !tier->isAnnouncing ))
if( tier->isAnnouncing )
st->announceState = TR_TRACKER_ACTIVE;
else if( !torrent->isRunning )
st->announceState = TR_TRACKER_INACTIVE;
else if( tierNeedsToAnnounce( tier, now ) )
st->announceState = TR_TRACKER_QUEUED;
else {
st->announceState = TR_TRACKER_WAITING;
st->nextAnnounceTime = tier->announceAt;
}
st->seederCount = tracker->seederCount;
st->leecherCount = tracker->leecherCount;

View File

@@ -374,15 +374,14 @@ 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, 24 );
tr_benc * d = tr_bencListAddDict( list, 22 );
tr_bencDictAddStr ( d, "announce", s->announce );
tr_bencDictAddInt ( d, "announceState", s->announceState );
tr_bencDictAddInt ( d, "downloadCount", s->downloadCount );
tr_bencDictAddBool( d, "hasAnnounced", s->hasAnnounced );
tr_bencDictAddBool( d, "hasScraped", s->hasScraped );
tr_bencDictAddStr ( d, "host", s->host );
tr_bencDictAddBool( d, "isActive", s->isActive );
tr_bencDictAddBool( d, "isAnnouncing", s->isAnnouncing );
tr_bencDictAddBool( d, "isScraping", s->isScraping );
tr_bencDictAddInt ( d, "lastAnnouncePeerCount", s->lastAnnouncePeerCount );
tr_bencDictAddStr ( d, "lastAnnounceResult", s->lastAnnounceResult );
tr_bencDictAddInt ( d, "lastAnnounceStartTime", s->lastAnnounceStartTime );
@@ -395,10 +394,9 @@ addTrackerStats( const tr_tracker_stat * st, int n, tr_benc * list )
tr_bencDictAddInt ( d, "leecherCount", s->leecherCount );
tr_bencDictAddInt ( d, "nextAnnounceTime", s->nextAnnounceTime );
tr_bencDictAddInt ( d, "nextScrapeTime", s->nextScrapeTime );
tr_bencDictAddInt ( d, "scrapeState", s->scrapeState );
tr_bencDictAddInt ( d, "seederCount", s->seederCount );
tr_bencDictAddInt ( d, "tier", s->tier );
tr_bencDictAddBool( d, "willAnnounce", s->willAnnounce );
tr_bencDictAddBool( d, "willScrape", s->willScrape );
}
}

View File

@@ -1230,6 +1230,25 @@ void tr_torrentPeersFree( tr_peer_stat * peerStats,
**** tr_tracker_stat
***/
typedef enum
{
/* we won't (announce,scrape) this torrent to this tracker because
* the torrent is stopped, or because of an error, or whatever */
TR_TRACKER_INACTIVE,
/* we will (announce,scrape) this torrent to this tracker, and are
* waiting for enough time to pass to satisfy the tracker's interval */
TR_TRACKER_WAITING,
/* it's time to (announce,scrape) this torrent, and we're waiting on a
* a free slot to open up in the announce manager */
TR_TRACKER_QUEUED,
/* we're (announcing,scraping) this torrent right now */
TR_TRACKER_ACTIVE
}
tr_tracker_state;
typedef struct
{
/* how many downloads this tracker knows of (-1 means it does not know) */
@@ -1251,11 +1270,11 @@ typedef struct
Transmission typically uses one tracker per tier. */
tr_bool isActive;
/* true if we've sent an announce and waiting for the response */
tr_bool isAnnouncing;
/* is the tracker announcing, waiting, queued, etc */
tr_tracker_state announceState;
/* true if we've got a scrape request pending right now */
tr_bool isScraping;
/* is the tracker scraping, waiting, queued, etc */
tr_tracker_state scrapeState;
/* number of peers the tracker told us about last time.
* if "lastAnnounceSucceeded" is false, this field is undefined */
@@ -1297,11 +1316,11 @@ typedef struct
int leecherCount;
/* when the next periodic announce message will be sent out.
if "willAnnounce" is false, this field is undefined */
if announceState isn't TR_TRACKER_WAITING, this field is undefined */
time_t nextAnnounceTime;
/* when the next periodic scrape message will be sent out.
if "willScrape" is false, this field is undefined */
if scrapeState isn't TR_TRACKER_WAITING, this field is undefined */
time_t nextScrapeTime;
/* number of seeders this tracker knows of (-1 means it does not know) */
@@ -1309,12 +1328,6 @@ typedef struct
/* which tier this tracker is in */
int tier;
/* true if the torrent's not announcing now, but will at nextAnnounceTime */
tr_bool willAnnounce;
/* true if we're not scraping now but will at nextScrapeTime */
tr_bool willScrape;
}
tr_tracker_stat;