Changeset 3260
- Timestamp:
- Oct 1, 2007, 4:31:17 PM (15 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-io.c
r3247 r3260 53 53 unsigned int peerIdIsSet : 1; 54 54 55 tr_ratecontrol * rateToPeer;56 tr_ratecontrol * rateToClient;57 58 55 tr_can_read_cb canRead; 59 56 tr_did_write_cb didWrite; … … 121 118 c->port = port; 122 119 c->socket = socket; 123 c->rateToPeer = tr_rcInit( );124 c->rateToClient = tr_rcInit( );125 120 c->isIncoming = isIncoming ? 1 : 0; 126 121 c->bufev = bufferevent_new( c->socket, … … 175 170 tr_netClose( c->socket ); 176 171 177 tr_rcClose( c->rateToClient );178 tr_rcClose( c->rateToPeer );179 180 172 tr_cryptoFree( c->crypto ); 181 173 … … 399 391 { 400 392 tr_bufferevent_write( io->handle, io->bufev, writeme, writeme_len ); 401 tr_rcTransferred( io->rateToPeer, writeme_len );402 393 } 403 394 … … 503 494 /*fprintf( stderr, "reading %d plaintext bytes from inbuf...\n", byteCount );*/ 504 495 evbuffer_remove( inbuf, bytes, byteCount ); 505 tr_rcTransferred( io->rateToClient, byteCount );506 496 break; 507 497 … … 510 500 evbuffer_remove( inbuf, bytes, byteCount ); 511 501 tr_cryptoDecrypt( io->crypto, byteCount, bytes, bytes ); 512 tr_rcTransferred( io->rateToClient, byteCount );513 502 break; 514 503 … … 555 544 tr_free( tmp ); 556 545 } 557 558 /**559 ***560 **/561 562 float563 tr_peerIoGetRateToClient( const tr_peerIo * io )564 {565 return io==NULL ? 0.0f : tr_rcRate( io->rateToClient );566 567 }568 569 float570 tr_peerIoGetRateToPeer( const tr_peerIo * io )571 {572 return io==NULL ? 0.0f : tr_rcRate( io->rateToPeer );573 }574 -
trunk/libtransmission/peer-io.h
r3242 r3260 122 122 123 123 124 float tr_peerIoGetRateToClient( const tr_peerIo * io );125 126 float tr_peerIoGetRateToPeer( const tr_peerIo * io );127 128 124 /** 129 125 *** -
trunk/libtransmission/peer-mgr-private.h
r3255 r3260 56 56 struct tr_peermsgs * msgs; 57 57 tr_publisher_tag msgsTag; 58 59 struct tr_ratecontrol * rateToClient; 60 struct tr_ratecontrol * rateToPeer; 58 61 } 59 62 tr_peer; -
trunk/libtransmission/peer-mgr.c
r3258 r3260 62 62 * with a better idea for managing the connection limits */ 63 63 MAX_CONNECTED_PEERS_PER_TORRENT = 60, 64 65 66 ADDED_F_ENCRYPTION_FLAG = 1, 67 ADDED_F_SEED_FLAG = 2 64 68 }; 69 65 70 66 71 /** … … 71 76 * it's connected or not, so the struct must be small. 72 77 * When our current connections underperform, we dip back 73 * int this list for new ones. */78 * into this list for new ones. */ 74 79 struct peer_atom 75 80 { … … 272 277 { 273 278 peer = tr_new0( tr_peer, 1 ); 279 peer->rateToClient = tr_rcInit( ); 280 peer->rateToPeer = tr_rcInit( ); 274 281 memcpy( &peer->in_addr, in_addr, sizeof(struct in_addr) ); 275 282 tr_ptrArrayInsertSorted( torrent->peers, peer, peerCompare ); … … 308 315 { 309 316 disconnectPeer( peer ); 317 tr_rcClose( peer->rateToClient ); 318 tr_rcClose( peer->rateToPeer ); 310 319 tr_free( peer->client ); 311 320 tr_free( peer ); … … 826 835 break; 827 836 828 case TR_PEERMSG_PEER_PROGRESS: { /* if we're both seeds, then disconnect. */ 829 #if 0 830 const int clientIsSeed = tr_cpGetStatus( t->tor->completion ) != TR_CP_INCOMPLETE; 837 case TR_PEERMSG_PEER_PROGRESS: { 838 struct peer_atom * atom = getExistingAtom( t, &peer->in_addr ); 831 839 const int peerIsSeed = e->progress >= 1.0; 832 if( clientIsSeed && peerIsSeed ) 833 peer->doPurge = 1; 834 #endif 840 if( peerIsSeed ) 841 atom->flags |= ADDED_F_SEED_FLAG; 842 else 843 atom->flags &= ~ADDED_F_SEED_FLAG; 835 844 break; 836 845 } … … 1096 1105 1097 1106 walk->flags = 0; 1098 if( peerPrefersCrypto(peer) ) walk->flags |= 1;1099 if( peer->progress >= 1.0 ) walk->flags |= 2;1107 if( peerPrefersCrypto(peer) ) walk->flags |= ADDED_F_ENCRYPTION_FLAG; 1108 if( peer->progress >= 1.0 ) walk->flags |= ADDED_F_SEED_FLAG; 1100 1109 } 1101 1110 … … 1296 1305 ++setmePeersFrom[atom->from]; 1297 1306 1298 if( tr_ peerIoGetRateToPeer( peer->io) > 0.01 )1307 if( tr_rcRate( peer->rateToPeer ) > 0.01 ) 1299 1308 ++*setmePeersGettingFromUs; 1300 1309 1301 if( tr_ peerIoGetRateToClient( peer->io) > 0.01 )1310 if( tr_rcRate( peer->rateToClient ) > 0.01 ) 1302 1311 ++*setmePeersSendingToUs; 1303 1312 } … … 1336 1345 stat->progress = peer->progress; 1337 1346 stat->isEncrypted = tr_peerIoIsEncrypted( peer->io ) ? 1 : 0; 1338 stat->uploadToRate = tr_ peerIoGetRateToPeer( peer->io);1339 stat->downloadFromRate = tr_ peerIoGetRateToClient( peer->io);1347 stat->uploadToRate = tr_rcRate( peer->rateToPeer ); 1348 stat->downloadFromRate = tr_rcRate( peer->rateToClient ); 1340 1349 stat->isDownloading = stat->uploadToRate > 0.01; 1341 1350 stat->isUploading = stat->downloadFromRate > 0.01; … … 1417 1426 node->preferred = peer->peerIsInterested && !clientIsSnubbedBy(peer); 1418 1427 node->randomKey = tr_rand( INT_MAX ); 1419 node->rate = tr_peerIoGetRateToClient( peer->io ); 1428 node->rate = (3*tr_rcRate(peer->rateToPeer)) 1429 + (1*tr_rcRate(peer->rateToClient)); 1420 1430 } 1421 1431 … … 1516 1526 const int peerIsSeed = peer->progress >= 1.0; 1517 1527 const struct peer_atom * atom = getExistingAtom( t, &peer->in_addr ); 1518 const double throughput = ( 2*tr_peerIoGetRateToPeer( peer->io))1519 + tr_peerIoGetRateToClient( peer->io);1528 const double throughput = (3*tr_rcRate(peer->rateToPeer)) 1529 + (1*tr_rcRate(peer->rateToClient)); 1520 1530 1521 1531 assert( atom != NULL ); … … 1580 1590 1581 1591 /* no need to connect if we're both seeds... */ 1582 if( seed && ( atom->flags & 2) ) {1592 if( seed && (atom->flags & ADDED_F_SEED_FLAG) ) { 1583 1593 fprintf( stderr, "RECONNECT peer %d (%s) is a seed and so are we...\n", i, tr_peerIoAddrStr(&atom->addr,atom->port) ); 1584 1594 continue; -
trunk/libtransmission/peer-msgs.c
r3243 r3260 489 489 return TR_ADDREQ_MISSING; 490 490 491 maxSize = MIN( 2 + (int)(tr_peerIoGetRateToClient(msgs->io)/10), 100 ); 492 //if( ( time(NULL) - msgs->lastReqAddedAt <= 5 ) && ( tr_list_size( msgs->clientAskedFor) >= maxSize ) ) 491 maxSize = MIN( 3 + (int)(tr_rcRate(msgs->info->rateToClient)/10), 100 ); 493 492 if( tr_list_size( msgs->clientAskedFor) >= maxSize ) 494 493 return TR_ADDREQ_FULL; … … 966 965 tor->activityDate = tr_date( ); 967 966 tor->downloadedCur += byteCount; 967 tr_rcTransferred( msgs->info->rateToClient, byteCount ); 968 968 tr_rcTransferred( tor->download, byteCount ); 969 969 tr_rcTransferred( tor->handle->download, byteCount ); … … 976 976 tor->activityDate = tr_date( ); 977 977 tor->uploadedCur += byteCount; 978 tr_rcTransferred( msgs->info->rateToPeer, byteCount ); 978 979 tr_rcTransferred( tor->upload, byteCount ); 979 980 tr_rcTransferred( tor->handle->upload, byteCount );
Note: See TracChangeset
for help on using the changeset viewer.