Changeset 9253
- Timestamp:
- Oct 9, 2009, 9:30:34 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/daemon/remote.c
r9179 r9253 1248 1248 const char * host; 1249 1249 tr_bool isActive; 1250 tr_bool isAnnouncing;1251 tr_bool isScraping;1252 1250 int64_t lastAnnouncePeerCount; 1253 1251 const char * lastAnnounceResult; … … 1264 1262 int64_t seederCount; 1265 1263 int64_t tier; 1266 tr_bool willAnnounce;1267 tr_bool willScrape;1264 int64_t announceState; 1265 int64_t scrapeState; 1268 1266 1269 1267 if( tr_bencDictFindInt ( t, "downloadCount", &downloadCount ) && … … 1272 1270 tr_bencDictFindStr ( t, "host", &host ) && 1273 1271 tr_bencDictFindBool( t, "isActive", &isActive ) && 1274 tr_bencDictFind Bool( t, "isAnnouncing", &isAnnouncing) &&1275 tr_bencDictFind Bool( t, "isScraping", &isScraping) &&1272 tr_bencDictFindInt ( t, "announceState", &announceState ) && 1273 tr_bencDictFindInt ( t, "scrapeState", &scrapeState ) && 1276 1274 tr_bencDictFindInt ( t, "lastAnnouncePeerCount", &lastAnnouncePeerCount ) && 1277 1275 tr_bencDictFindStr ( t, "lastAnnounceResult", &lastAnnounceResult ) && … … 1287 1285 tr_bencDictFindInt ( t, "nextScrapeTime", &nextScrapeTime ) && 1288 1286 tr_bencDictFindInt ( t, "seederCount", &seederCount ) && 1289 tr_bencDictFindInt ( t, "tier", &tier ) && 1290 tr_bencDictFindBool( t, "willAnnounce", &willAnnounce ) && 1291 tr_bencDictFindBool( t, "willScrape", &willScrape ) ) 1287 tr_bencDictFindInt ( t, "tier", &tier ) ) 1292 1288 { 1293 1289 const time_t now = time( NULL ); … … 1311 1307 } 1312 1308 1313 if( isActive && ( isAnnouncing || willAnnounce ) ) { 1314 if( !isAnnouncing ) { 1309 if( isActive ) switch( announceState ) { 1310 case TR_TRACKER_INACTIVE: 1311 printf( " No updates scheduled\n" ); 1312 break; 1313 case TR_TRACKER_WAITING: 1315 1314 tr_strltime( buf, nextAnnounceTime - now, sizeof( buf ) ); 1316 1315 printf( " Asking for more peers in %s\n", buf ); 1317 } else { 1316 break; 1317 case TR_TRACKER_QUEUED: 1318 printf( " Queued to ask for more peers\n" ); 1319 break; 1320 case TR_TRACKER_ACTIVE: 1318 1321 tr_strltime( buf, now - lastAnnounceStartTime, sizeof( buf ) ); 1319 1322 printf( " Asking for more peers now... %s\n", buf ); 1320 }1323 break; 1321 1324 } 1322 1325 1323 if( !hasAnnounced && !isAnnouncing && !willAnnounce ) 1324 printf( " No updates scheduled\n" ); 1325 1326 if( isActive && hasScraped ) { 1326 if( isActive && hasScraped ) 1327 { 1327 1328 tr_strltime( buf, now - lastScrapeTime, sizeof( buf ) ); 1328 1329 if( lastScrapeSucceeded ) … … 1334 1335 } 1335 1336 1336 if( isScraping || willScrape ) { 1337 if( !isScraping ) { 1337 switch( scrapeState ) { 1338 case TR_TRACKER_INACTIVE: 1339 break; 1340 case TR_TRACKER_WAITING: 1338 1341 tr_strltime( buf, nextScrapeTime - now, sizeof( buf ) ); 1339 1342 printf( " Asking for peer counts in %s\n", buf ); 1340 } else { 1343 break; 1344 case TR_TRACKER_QUEUED: 1345 printf( " Queued to ask for peer counts\n" ); 1346 break; 1347 case TR_TRACKER_ACTIVE: 1341 1348 tr_strltime( buf, now - lastScrapeStartTime, sizeof( buf ) ); 1342 1349 printf( " Asking for peer counts now... %s\n", buf ); 1343 }1350 break; 1344 1351 } 1345 1352 } -
trunk/doc/rpc-spec.txt
r9179 r9253 252 252 +-------------------------+------------+ 253 253 | announce | string | tr_tracker_stat 254 | announceState | number | tr_tracker_stat 254 255 | downloadCount | number | tr_tracker_stat 255 256 | hasAnnounced | boolean | tr_tracker_stat … … 257 258 | host | string | tr_tracker_stat 258 259 | isActive | boolean | tr_tracker_stat 259 | isAnnouncing | boolean | tr_tracker_stat260 | isScraping | boolean | tr_tracker_stat261 260 | lastAnnouncePeerCount | number | tr_tracker_stat 262 261 | lastAnnounceResult | number | tr_tracker_stat … … 271 270 | nextAnnounceTime | number | tr_tracker_stat 272 271 | nextScrapeTime | number | tr_tracker_stat 272 | scrapeState | number | tr_tracker_stat 273 273 | seederCount | number | tr_tracker_stat 274 274 | tier | number | tr_tracker_stat 275 | willAnnounce | boolean | tr_tracker_stat276 | willScrape | boolean | tr_tracker_stat277 275 -------------------+-------------------------+------------+ 278 276 wanted | an array of tr_info.fileCount | tr_info -
trunk/gtk/details.c
r9242 r9253 1636 1636 } 1637 1637 1638 if( st->isActive && ( st->isAnnouncing || st->willAnnounce ) ) { 1639 g_string_append_c( gstr, '\n' ); 1640 if( !st->isAnnouncing ) { 1638 if( st->isActive ) switch( st->announceState ) { 1639 case TR_TRACKER_INACTIVE: 1640 if( !st->hasAnnounced ) { 1641 g_string_append_c( gstr, '\n' ); 1642 g_string_append( gstr, _( "No updates scheduled" ) ); 1643 } 1644 break; 1645 case TR_TRACKER_WAITING: 1641 1646 tr_strltime_rounded( timebuf, st->nextAnnounceTime - now, sizeof( timebuf ) ); 1647 g_string_append_c( gstr, '\n' ); 1642 1648 g_string_append_printf( gstr, _( "Asking for more peers in %s" ), timebuf ); 1643 } else { 1649 break; 1650 case TR_TRACKER_QUEUED: 1651 g_string_append_c( gstr, '\n' ); 1652 g_string_append( gstr, _( "Queued to ask for more peers" ) ); 1653 break; 1654 case TR_TRACKER_ACTIVE: 1644 1655 tr_strltime_rounded( timebuf, now - st->lastAnnounceStartTime, sizeof( timebuf ) ); 1645 1656 g_string_append_printf( gstr, _( "Asking for more peers now... <small>%s</small>" ), timebuf ); 1646 } 1647 } 1648 1649 if( !st->hasAnnounced && !st->isAnnouncing && !st->willAnnounce ) { 1650 g_string_append_c( gstr, '\n' ); 1651 g_string_append( gstr, _( "No updates scheduled" ) ); 1657 break; 1652 1658 } 1653 1659 … … 1665 1671 } 1666 1672 1667 if( st->isScraping || st->willScrape ) { 1668 g_string_append_c( gstr, '\n' ); 1669 if( !st->isScraping ) { 1673 switch( st->scrapeState ) 1674 { 1675 case TR_TRACKER_INACTIVE: 1676 break; 1677 case TR_TRACKER_WAITING: 1678 g_string_append_c( gstr, '\n' ); 1679 tr_strltime_rounded( timebuf, now - st->lastScrapeStartTime, sizeof( timebuf ) ); 1680 g_string_append_printf( gstr, _( "Asking for peer counts now... <small>%s</small>" ), timebuf ); 1681 break; 1682 case TR_TRACKER_QUEUED: 1683 g_string_append_c( gstr, '\n' ); 1684 g_string_append( gstr, _( "Queued to ask for peer counts" ) ); 1685 break; 1686 case TR_TRACKER_ACTIVE: 1687 g_string_append_c( gstr, '\n' ); 1670 1688 tr_strltime_rounded( timebuf, st->nextScrapeTime - now, sizeof( timebuf ) ); 1671 1689 g_string_append_printf( gstr, _( "Asking for peer counts in %s" ), timebuf ); 1672 } else { 1673 tr_strltime_rounded( timebuf, now - st->lastScrapeStartTime, sizeof( timebuf ) ); 1674 g_string_append_printf( gstr, _( "Asking for peer counts now... <small>%s</small>" ), timebuf ); 1675 } 1676 } 1677 } 1678 1690 break; 1691 } 1692 } 1693 1679 1694 return g_string_free( gstr, FALSE ); 1680 1695 } -
trunk/libtransmission/announcer.c
r9240 r9253 1635 1635 int tierCount; 1636 1636 tr_tracker_stat * ret; 1637 const time_t now = time( NULL ); 1637 1638 1638 1639 assert( tr_isTorrent( torrent ) ); … … 1671 1672 st->lastScrapeSucceeded = FALSE; 1672 1673 st->lastScrapeResult[0] = '\0'; 1673 st-> isScraping = FALSE;1674 st-> willScrape = FALSE;1674 st->scrapeState = TR_TRACKER_INACTIVE; 1675 st->announceState = TR_TRACKER_INACTIVE; 1675 1676 st->nextScrapeTime = 0; 1676 1677 st->lastAnnounceStartTime = 0; … … 1680 1681 st->lastAnnounceSucceeded = FALSE; 1681 1682 st->lastAnnouncePeerCount = 0; 1682 st->isAnnouncing = FALSE;1683 st->willAnnounce = FALSE;1684 1683 st->nextAnnounceTime = 0; 1685 1684 st->seederCount = 0; … … 1695 1694 } 1696 1695 1697 st->isScraping = tier->isScraping; 1698 1699 if(( st->willScrape = !tier->isScraping )) 1696 if( tier->isScraping ) 1697 st->scrapeState = TR_TRACKER_ACTIVE; 1698 else if( tierNeedsToScrape( tier, now ) ) 1699 st->scrapeState = TR_TRACKER_QUEUED; 1700 else { 1701 st->scrapeState = TR_TRACKER_WAITING; 1700 1702 st->nextScrapeTime = tier->scrapeAt; 1703 } 1701 1704 1702 1705 st->lastAnnounceStartTime = tier->lastAnnounceStartTime; … … 1710 1713 } 1711 1714 1712 st->isAnnouncing = tier->isAnnouncing; 1713 1714 if(( st->willAnnounce = torrent->isRunning && !tier->isAnnouncing )) 1715 if( tier->isAnnouncing ) 1716 st->announceState = TR_TRACKER_ACTIVE; 1717 else if( !torrent->isRunning ) 1718 st->announceState = TR_TRACKER_INACTIVE; 1719 else if( tierNeedsToAnnounce( tier, now ) ) 1720 st->announceState = TR_TRACKER_QUEUED; 1721 else { 1722 st->announceState = TR_TRACKER_WAITING; 1715 1723 st->nextAnnounceTime = tier->announceAt; 1724 } 1716 1725 1717 1726 st->seederCount = tracker->seederCount; -
trunk/libtransmission/rpcimpl.c
r9179 r9253 375 375 { 376 376 const tr_tracker_stat * s = &st[i]; 377 tr_benc * d = tr_bencListAddDict( list, 2 4);377 tr_benc * d = tr_bencListAddDict( list, 22 ); 378 378 tr_bencDictAddStr ( d, "announce", s->announce ); 379 tr_bencDictAddInt ( d, "announceState", s->announceState ); 379 380 tr_bencDictAddInt ( d, "downloadCount", s->downloadCount ); 380 381 tr_bencDictAddBool( d, "hasAnnounced", s->hasAnnounced ); … … 382 383 tr_bencDictAddStr ( d, "host", s->host ); 383 384 tr_bencDictAddBool( d, "isActive", s->isActive ); 384 tr_bencDictAddBool( d, "isAnnouncing", s->isAnnouncing );385 tr_bencDictAddBool( d, "isScraping", s->isScraping );386 385 tr_bencDictAddInt ( d, "lastAnnouncePeerCount", s->lastAnnouncePeerCount ); 387 386 tr_bencDictAddStr ( d, "lastAnnounceResult", s->lastAnnounceResult ); … … 396 395 tr_bencDictAddInt ( d, "nextAnnounceTime", s->nextAnnounceTime ); 397 396 tr_bencDictAddInt ( d, "nextScrapeTime", s->nextScrapeTime ); 397 tr_bencDictAddInt ( d, "scrapeState", s->scrapeState ); 398 398 tr_bencDictAddInt ( d, "seederCount", s->seederCount ); 399 399 tr_bencDictAddInt ( d, "tier", s->tier ); 400 tr_bencDictAddBool( d, "willAnnounce", s->willAnnounce );401 tr_bencDictAddBool( d, "willScrape", s->willScrape );402 400 } 403 401 } -
trunk/libtransmission/transmission.h
r9213 r9253 1231 1231 ***/ 1232 1232 1233 typedef enum 1234 { 1235 /* we won't (announce,scrape) this torrent to this tracker because 1236 * the torrent is stopped, or because of an error, or whatever */ 1237 TR_TRACKER_INACTIVE, 1238 1239 /* we will (announce,scrape) this torrent to this tracker, and are 1240 * waiting for enough time to pass to satisfy the tracker's interval */ 1241 TR_TRACKER_WAITING, 1242 1243 /* it's time to (announce,scrape) this torrent, and we're waiting on a 1244 * a free slot to open up in the announce manager */ 1245 TR_TRACKER_QUEUED, 1246 1247 /* we're (announcing,scraping) this torrent right now */ 1248 TR_TRACKER_ACTIVE 1249 } 1250 tr_tracker_state; 1251 1233 1252 typedef struct 1234 1253 { … … 1252 1271 tr_bool isActive; 1253 1272 1254 /* true if we've sent an announce and waiting for the response*/1255 tr_ bool isAnnouncing;1256 1257 /* true if we've got a scrape request pending right now*/1258 tr_ bool isScraping;1273 /* is the tracker announcing, waiting, queued, etc */ 1274 tr_tracker_state announceState; 1275 1276 /* is the tracker scraping, waiting, queued, etc */ 1277 tr_tracker_state scrapeState; 1259 1278 1260 1279 /* number of peers the tracker told us about last time. … … 1298 1317 1299 1318 /* when the next periodic announce message will be sent out. 1300 if "willAnnounce" is false, this field is undefined */1319 if announceState isn't TR_TRACKER_WAITING, this field is undefined */ 1301 1320 time_t nextAnnounceTime; 1302 1321 1303 1322 /* when the next periodic scrape message will be sent out. 1304 if "willScrape" is false, this field is undefined */1323 if scrapeState isn't TR_TRACKER_WAITING, this field is undefined */ 1305 1324 time_t nextScrapeTime; 1306 1325 … … 1310 1329 /* which tier this tracker is in */ 1311 1330 int tier; 1312 1313 /* true if the torrent's not announcing now, but will at nextAnnounceTime */1314 tr_bool willAnnounce;1315 1316 /* true if we're not scraping now but will at nextScrapeTime */1317 tr_bool willScrape;1318 1331 } 1319 1332 tr_tracker_stat;
Note: See TracChangeset
for help on using the changeset viewer.