Changeset 7238 for trunk/libtransmission/peer-mgr.c
- Timestamp:
- Dec 2, 2008, 7:46:51 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.