Changeset 7238
- Timestamp:
- Dec 2, 2008, 7:46:51 PM (12 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-common.h
r7234 r7238 49 49 TR_PEER_ERROR, 50 50 TR_PEER_CANCEL, 51 TR_PEER_UPLOAD_ONLY, 51 52 TR_PEER_NEED_REQ 52 53 } … … 62 63 int err; /* errno for GOT_ERROR */ 63 64 int wasPieceData; /* for GOT_DATA */ 65 tr_bool uploadOnly; /* for UPLOAD_ONLY */ 64 66 } 65 67 tr_peer_event; -
trunk/libtransmission/peer-mgr.c
r7236 r7238 90 90 **/ 91 91 92 enum 93 { 94 UPLOAD_ONLY_UKNOWN, 95 UPLOAD_ONLY_YES, 96 UPLOAD_ONLY_NO 97 }; 98 92 99 /* We keep one of these for every peer we know about, whether 93 100 * it's connected or not, so the struct must be small. … … 97 104 { 98 105 uint8_t from; 99 uint8_t flags; /* these match the added_f flags */ 100 uint8_t myflags; /* flags that aren't defined in added_f */ 106 uint8_t flags; /* these match the added_f flags */ 107 uint8_t myflags; /* flags that aren't defined in added_f */ 108 uint8_t uploadOnly; /* UPLOAD_ONLY_ */ 109 uint8_t partialSeed; 101 110 tr_port port; 102 111 uint16_t numFails; 103 112 tr_address addr; 104 time_t time; /* when the peer's connection status last changed */113 time_t time; /* when the peer's connection status last changed */ 105 114 time_t piece_data_time; 106 115 }; … … 981 990 switch( e->eventType ) 982 991 { 992 case TR_PEER_UPLOAD_ONLY: 993 /* update our atom */ 994 if( peer ) { 995 struct peer_atom * a = getExistingAtom( t, &peer->addr ); 996 a->uploadOnly = e->uploadOnly ? UPLOAD_ONLY_YES : UPLOAD_ONLY_NO; 997 } 998 break; 999 983 1000 case TR_PEER_NEED_REQ: 984 1001 refillSoon( t ); … … 1459 1476 { 1460 1477 const tr_peer * peer = peers[i]; 1478 const struct peer_atom * atom = getExistingAtom( t, &peer->addr ); 1479 1461 1480 walk->addr = peer->addr; 1462 1481 walk->port = peer->port; 1463 1482 walk->flags = 0; 1464 if( peerPrefersCrypto( peer ) ) walk->flags |= ADDED_F_ENCRYPTION_FLAG; 1465 if( peer->progress >= 1.0 ) walk->flags |= ADDED_F_SEED_FLAG; 1483 if( peerPrefersCrypto( peer ) ) 1484 walk->flags |= ADDED_F_ENCRYPTION_FLAG; 1485 if( ( atom->uploadOnly == UPLOAD_ONLY_YES ) || ( peer->progress >= 1.0 ) ) 1486 walk->flags |= ADDED_F_SEED_FLAG; 1466 1487 } 1467 1488 … … 1885 1906 { 1886 1907 tr_peer * peer = peers[i]; 1908 struct peer_atom * atom = getExistingAtom( t, &peer->addr ); 1909 1887 1910 if( peer->progress >= 1.0 ) /* choke all seeds */ 1911 { 1888 1912 tr_peerMsgsSetChoke( peer->msgs, TRUE ); 1889 else if( chokeAll ) 1913 } 1914 else if( atom->uploadOnly == UPLOAD_ONLY_YES ) /* choke partial seeds */ 1915 { 1890 1916 tr_peerMsgsSetChoke( peer->msgs, TRUE ); 1891 else { 1917 } 1918 else if( chokeAll ) /* choke everyone if we're not uploading */ 1919 { 1920 tr_peerMsgsSetChoke( peer->msgs, TRUE ); 1921 } 1922 else 1923 { 1892 1924 struct ChokeData * n = &choke[size++]; 1893 1925 n->peer = peer; … … 2176 2208 2177 2209 /* no need to connect if we're both seeds... */ 2178 if( seed && ( atom->flags & ADDED_F_SEED_FLAG ) ) 2210 if( seed && ( ( atom->flags & ADDED_F_SEED_FLAG ) || 2211 ( atom->uploadOnly == UPLOAD_ONLY_YES ) ) ) 2179 2212 continue; 2180 2213 -
trunk/libtransmission/peer-msgs.c
r7237 r7238 514 514 **/ 515 515 516 static const tr_peer_event blankEvent = { 0, 0, 0, 0, 0.0f, 0, 0 };516 static const tr_peer_event blankEvent = { 0, 0, 0, 0, 0.0f, 0, 0, 0 }; 517 517 518 518 static void … … 538 538 539 539 static void 540 fireUploadOnly( tr_peermsgs * msgs, tr_bool uploadOnly ) 541 { 542 tr_peer_event e = blankEvent; 543 e.eventType = TR_PEER_UPLOAD_ONLY; 544 e.uploadOnly = uploadOnly; 545 publish( msgs, &e ); 546 } 547 548 static void 540 549 fireNeedReq( tr_peermsgs * msgs ) 541 550 { 542 551 tr_peer_event e = blankEvent; 543 544 552 e.eventType = TR_PEER_NEED_REQ; 545 553 publish( msgs, &e ); … … 1087 1095 1088 1096 tr_bencInitDict( &val, 4 ); 1089 tr_bencDictAddInt( &val, "e", 1090 msgs->session->encryptionMode != TR_CLEAR_PREFERRED ); 1097 tr_bencDictAddInt( &val, "e", msgs->session->encryptionMode != TR_CLEAR_PREFERRED ); 1091 1098 tr_bencDictAddInt( &val, "p", tr_sessionGetPeerPort( msgs->session ) ); 1099 tr_bencDictAddInt( &val, "upload_only", tr_torrentIsSeed( msgs->torrent ) ); 1092 1100 tr_bencDictAddStr( &val, "v", TR_NAME " " USERAGENT_PREFIX ); 1093 1101 m = tr_bencDictAddDict( &val, "m", 1 ); … … 1145 1153 } 1146 1154 } 1155 1156 /* look for upload_only (BEP 21) */ 1157 if( tr_bencDictFindInt( &val, "upload_only", &i ) ) 1158 fireUploadOnly( msgs, i!=0 ); 1147 1159 1148 1160 /* get peer's listening port */ -
trunk/libtransmission/rpcimpl.c
r7132 r7238 292 292 else if( !strcmp( key, "downloadedEver" ) ) 293 293 tr_bencDictAddInt( d, key, st->downloadedEver ); 294 else if( !strcmp( key, "downloaders" ) ) 295 tr_bencDictAddInt( d, key, st->downloaders ); 294 296 else if( !strcmp( key, "downloadLimitMode" ) ) 295 297 tr_bencDictAddInt( d, key, tr_torrentGetSpeedMode( tor, TR_DOWN ) ); -
trunk/libtransmission/torrent.c
r7235 r7238 784 784 s->scrapeURL = ti ? ti->scrape : NULL; 785 785 tr_trackerStat( tc, s ); 786 786 787 tr_trackerGetCounts( tc, &s->timesCompleted, 787 &s->leechers, 788 &s->seeders ); 788 &s->leechers, 789 &s->seeders, 790 &s->downloaders ); 791 789 792 tr_peerMgrTorrentStats( tor->session->peerMgr, 790 793 tor->info.hash, -
trunk/libtransmission/tracker.c
r7235 r7238 109 109 int timesDownloaded; 110 110 int seederCount; 111 int downloaderCount; 111 112 int leecherCount; 112 113 char * trackerID; … … 539 540 const void * response, 540 541 size_t responseLen, 541 void *torrent_hash )542 void * torrent_hash ) 542 543 { 543 544 int success = FALSE; … … 584 585 t->timesDownloaded = itmp; 585 586 587 if( ( tr_bencDictFindInt( tordict, "downloaders", &itmp ) ) ) 588 t->downloaderCount = itmp; 589 586 590 if( tr_bencDictFindDict( tordict, "flags", &flags ) ) 587 if( ( tr_bencDictFindInt( flags, "min_request_interval", 588 &itmp ) ) ) 591 if( ( tr_bencDictFindInt( flags, "min_request_interval", &itmp ) ) ) 589 592 t->scrapeIntervalSec = i; 590 593 … … 652 655 TR_REQ_COMPLETED, 653 656 TR_REQ_STOPPED, 657 TR_REQ_PAUSED, /* BEP 21 */ 654 658 TR_REQ_REANNOUNCE, 655 TR_REQ_SCRAPE, 656 TR_REQ_COUNT 659 TR_REQ_SCRAPE 657 660 }; 658 661 … … 713 716 714 717 static struct tr_tracker_request* 715 createRequest( tr_session * session, 716 tr_tracker * tracker, 717 int reqtype ) 718 { 719 static const char* strings[] = 720 { "started", "completed", "stopped", "", "err" }; 721 const tr_torrent * torrent = tr_torrentFindFromHash( 722 session, tracker->hash ); 723 const tr_tracker_info * address = getCurrentAddressFromTorrent( 724 tracker, torrent ); 725 const int isStopping = reqtype == TR_REQ_STOPPED; 718 createRequest( tr_session * session, 719 tr_tracker * tracker, 720 int reqtype ) 721 { 722 static const char* strings[] = { "started", "completed", "stopped", "paused", "", "err" }; 723 const tr_torrent * torrent = tr_torrentFindFromHash( session, tracker->hash ); 724 const tr_tracker_info * address = getCurrentAddressFromTorrent( tracker, torrent ); 725 int isStopping; 726 726 struct tr_tracker_request * req; 727 struct evbuffer * url; 727 struct evbuffer * url; 728 729 /* BEP 21: In order to tell the tracker that a peer is a partial seed, it MUST send 730 * an event=paused parameter in every announce while it is a partial seed. */ 731 if( tr_cpGetStatus( torrent->completion ) == TR_PARTIAL_SEED ) 732 reqtype = TR_REQ_PAUSED; 733 734 isStopping = reqtype == TR_REQ_STOPPED; 728 735 729 736 url = evbuffer_new( ); … … 981 988 t->timesDownloaded = -1; 982 989 t->seederCount = -1; 990 t->downloaderCount = -1; 983 991 t->leecherCount = -1; 984 992 t->lastAnnounceResponse = -1; … … 1061 1069 void 1062 1070 tr_trackerGetCounts( const tr_tracker * t, 1063 int * setme_completedCount, 1064 int * setme_leecherCount, 1065 int * setme_seederCount ) 1071 int * setme_completedCount, 1072 int * setme_leecherCount, 1073 int * setme_seederCount, 1074 int * setme_downloaderCount ) 1066 1075 { 1067 1076 if( setme_completedCount ) … … 1073 1082 if( setme_seederCount ) 1074 1083 *setme_seederCount = t->seederCount; 1084 1085 if( setme_downloaderCount ) 1086 *setme_downloaderCount = t->downloaderCount; 1075 1087 } 1076 1088 -
trunk/libtransmission/tracker.h
r7235 r7238 98 98 int * setme_completedCount, 99 99 int * setme_leecherCount, 100 int * setme_seederCount ); 100 int * setme_seederCount, 101 int * setme_downloaderCount ); 101 102 102 103 #endif -
trunk/libtransmission/transmission.h
r7231 r7238 1324 1324 int leechers; 1325 1325 1326 /** Number of downloaders that the tracker says this torrent has. 1327 This is a new key introduced in BEP 21 and may not be supported by some trackers. 1328 If the tracker doesn't support this key, the value here will be -1. */ 1329 int downloaders; 1330 1326 1331 /** Number of finished downloads that the tracker says torrent has */ 1327 1332 int timesCompleted; -
trunk/libtransmission/webseed.c
r7173 r7238 52 52 ***/ 53 53 54 static const tr_peer_event blankEvent = { 0, 0, 0, 0, 0.0f, 0, 0 };54 static const tr_peer_event blankEvent = { 0, 0, 0, 0, 0.0f, 0, 0, 0 }; 55 55 56 56 static void
Note: See TracChangeset
for help on using the changeset viewer.