Changeset 3260


Ignore:
Timestamp:
Oct 1, 2007, 4:31:17 PM (15 years ago)
Author:
charles
Message:

don't log BT protocol messages in UL/DL speed -- only log piece data transfers.

Location:
trunk/libtransmission
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-io.c

    r3247 r3260  
    5353    unsigned int peerIdIsSet : 1;
    5454
    55     tr_ratecontrol   * rateToPeer;
    56     tr_ratecontrol   * rateToClient;
    57 
    5855    tr_can_read_cb     canRead;
    5956    tr_did_write_cb    didWrite;
     
    121118    c->port = port;
    122119    c->socket = socket;
    123     c->rateToPeer = tr_rcInit( );
    124     c->rateToClient = tr_rcInit( );
    125120    c->isIncoming = isIncoming ? 1 : 0;
    126121    c->bufev = bufferevent_new( c->socket,
     
    175170        tr_netClose( c->socket );
    176171
    177         tr_rcClose( c->rateToClient );
    178         tr_rcClose( c->rateToPeer );
    179 
    180172        tr_cryptoFree( c->crypto );
    181173
     
    399391{
    400392    tr_bufferevent_write( io->handle, io->bufev, writeme, writeme_len );
    401     tr_rcTransferred( io->rateToPeer, writeme_len );
    402393}
    403394
     
    503494            /*fprintf( stderr, "reading %d plaintext bytes from inbuf...\n", byteCount );*/
    504495            evbuffer_remove(  inbuf, bytes, byteCount );
    505             tr_rcTransferred( io->rateToClient, byteCount );
    506496            break;
    507497
     
    510500            evbuffer_remove(  inbuf, bytes, byteCount );
    511501            tr_cryptoDecrypt( io->crypto, byteCount, bytes, bytes );
    512             tr_rcTransferred( io->rateToClient, byteCount );
    513502            break;
    514503
     
    555544    tr_free( tmp );
    556545}
    557 
    558 /**
    559 ***
    560 **/
    561 
    562 float
    563 tr_peerIoGetRateToClient( const tr_peerIo * io )
    564 {
    565     return io==NULL ? 0.0f : tr_rcRate( io->rateToClient );
    566 
    567 }
    568 
    569 float
    570 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  
    122122
    123123
    124 float tr_peerIoGetRateToClient( const tr_peerIo * io );
    125 
    126 float tr_peerIoGetRateToPeer( const tr_peerIo * io );
    127 
    128124/**
    129125***
  • trunk/libtransmission/peer-mgr-private.h

    r3255 r3260  
    5656    struct tr_peermsgs * msgs;
    5757    tr_publisher_tag msgsTag;
     58
     59    struct tr_ratecontrol * rateToClient;
     60    struct tr_ratecontrol * rateToPeer;
    5861}
    5962tr_peer;
  • trunk/libtransmission/peer-mgr.c

    r3258 r3260  
    6262     * with a better idea for managing the connection limits */
    6363    MAX_CONNECTED_PEERS_PER_TORRENT = 60,
     64
     65
     66    ADDED_F_ENCRYPTION_FLAG = 1,
     67    ADDED_F_SEED_FLAG = 2
    6468};
     69
    6570
    6671/**
     
    7176 * it's connected or not, so the struct must be small.
    7277 * When our current connections underperform, we dip back
    73  * int this list for new ones. */
     78 * into this list for new ones. */
    7479struct peer_atom
    7580{   
     
    272277    {
    273278        peer = tr_new0( tr_peer, 1 );
     279        peer->rateToClient = tr_rcInit( );
     280        peer->rateToPeer = tr_rcInit( );
    274281        memcpy( &peer->in_addr, in_addr, sizeof(struct in_addr) );
    275282        tr_ptrArrayInsertSorted( torrent->peers, peer, peerCompare );
     
    308315{
    309316    disconnectPeer( peer );
     317    tr_rcClose( peer->rateToClient );
     318    tr_rcClose( peer->rateToPeer );
    310319    tr_free( peer->client );
    311320    tr_free( peer );
     
    826835            break;
    827836
    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 );
    831839            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;
    835844            break;
    836845        }
     
    10961105
    10971106        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;
    11001109    }
    11011110
     
    12961305        ++setmePeersFrom[atom->from];
    12971306
    1298         if( tr_peerIoGetRateToPeer( peer->io ) > 0.01 )
     1307        if( tr_rcRate( peer->rateToPeer ) > 0.01 )
    12991308            ++*setmePeersGettingFromUs;
    13001309
    1301         if( tr_peerIoGetRateToClient( peer->io ) > 0.01 )
     1310        if( tr_rcRate( peer->rateToClient ) > 0.01 )
    13021311            ++*setmePeersSendingToUs;
    13031312    }
     
    13361345        stat->progress         = peer->progress;
    13371346        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 );
    13401349        stat->isDownloading    = stat->uploadToRate > 0.01;
    13411350        stat->isUploading      = stat->downloadFromRate > 0.01;
     
    14171426        node->preferred = peer->peerIsInterested && !clientIsSnubbedBy(peer);
    14181427        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));
    14201430    }
    14211431
     
    15161526        const int peerIsSeed = peer->progress >= 1.0;
    15171527        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));
    15201530
    15211531        assert( atom != NULL );
     
    15801590
    15811591        /* no need to connect if we're both seeds... */
    1582         if( seed && ( atom->flags & 2 ) ) {
     1592        if( seed && (atom->flags & ADDED_F_SEED_FLAG) ) {
    15831593            fprintf( stderr, "RECONNECT peer %d (%s) is a seed and so are we...\n", i, tr_peerIoAddrStr(&atom->addr,atom->port) );
    15841594            continue;
  • trunk/libtransmission/peer-msgs.c

    r3243 r3260  
    489489        return TR_ADDREQ_MISSING;
    490490
    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 );
    493492    if( tr_list_size( msgs->clientAskedFor) >= maxSize )
    494493        return TR_ADDREQ_FULL;
     
    966965    tor->activityDate = tr_date( );
    967966    tor->downloadedCur += byteCount;
     967    tr_rcTransferred( msgs->info->rateToClient, byteCount );
    968968    tr_rcTransferred( tor->download, byteCount );
    969969    tr_rcTransferred( tor->handle->download, byteCount );
     
    976976    tor->activityDate = tr_date( );
    977977    tor->uploadedCur += byteCount;
     978    tr_rcTransferred( msgs->info->rateToPeer, byteCount );
    978979    tr_rcTransferred( tor->upload, byteCount );
    979980    tr_rcTransferred( tor->handle->upload, byteCount );
Note: See TracChangeset for help on using the changeset viewer.