Changeset 2963


Ignore:
Timestamp:
Sep 1, 2007, 3:17:40 AM (15 years ago)
Author:
charles
Message:

get per-peer ul/dl rate measurement working again.

Location:
branches/encryption/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/encryption/libtransmission/peer-io.c

    r2956 r2963  
    2121#include "net.h"
    2222#include "peer-io.h"
     23#include "ratecontrol.h"
    2324#include "trevent.h"
    2425#include "utils.h"
     
    4344    unsigned int isIncoming : 1;
    4445    unsigned int peerIdIsSet : 1;
     46
     47    tr_ratecontrol   * rateToPeer;
     48    tr_ratecontrol   * rateToClient;
    4549
    4650    tr_can_read_cb     canRead;
     
    107111    c->in_addr = *in_addr;
    108112    c->socket = socket;
     113    c->rateToPeer = tr_rcInit( );
     114    c->rateToClient = tr_rcInit( );
    109115    c->bufev = bufferevent_new( c->socket,
    110116                                canReadWrapper,
     
    149155{
    150156    bufferevent_free( c->bufev );
     157    tr_rcClose( c->rateToClient );
     158    tr_rcClose( c->rateToPeer );
    151159    tr_netClose( c->socket );
    152160    tr_cryptoFree( c->crypto );
     
    301309{
    302310    tr_bufferevent_write( io->handle, io->bufev, writeme, writeme_len );
     311    tr_rcTransferred( io->rateToPeer, writeme_len );
    303312}
    304313
     
    389398            fprintf( stderr, "reading %d plaintext bytes from inbuf...\n", byteCount );
    390399            evbuffer_remove(  inbuf, bytes, byteCount );
     400            tr_rcTransferred( io->rateToClient, byteCount );
    391401            break;
    392402
     
    395405            evbuffer_remove(  inbuf, bytes, byteCount );
    396406            tr_cryptoDecrypt( io->crypto, byteCount, bytes, bytes );
     407            tr_rcTransferred( io->rateToClient, byteCount );
    397408            break;
    398409
     
    431442    tr_free( tmp );
    432443}
     444
     445/**
     446***
     447**/
     448
     449float
     450tr_peerIoGetRateToClient( const tr_peerIo * io )
     451{
     452    return io==NULL ? 0.0f : tr_rcRate( io->rateToClient );
     453
     454}
     455
     456float
     457tr_peerIoGetRateToPeer( const tr_peerIo * io )
     458{
     459    return io==NULL ? 0.0f : tr_rcRate( io->rateToPeer );
     460}
     461
  • branches/encryption/libtransmission/peer-io.h

    r2954 r2963  
    88 * the Transmission project.
    99 *
    10  * $Id:$
     10 * $Id$
    1111 */
    1212
     
    116116                        const struct evbuffer * buf );
    117117
     118
     119float tr_peerIoGetRateToClient( const tr_peerIo * io );
     120
     121float tr_peerIoGetRateToPeer( const tr_peerIo * io );
     122
    118123/**
    119124***
  • branches/encryption/libtransmission/peer-mgr.c

    r2956 r2963  
    363363    {
    364364        const Peer * peer = peers[i];
     365        const int live = peer->io != NULL;
    365366        tr_peer_stat * stat = ret + i;
    366367
     
    368369        stat->port = peer->port;
    369370        stat->from = peer->from;
    370         stat->isConnected = peer->io != NULL;
     371        stat->isConnected = live;
     372        stat->uploadToRate     = tr_peerIoGetRateToPeer( peer->io );
     373        stat->downloadFromRate = tr_peerIoGetRateToClient( peer->io );
     374        stat->isDownloading    =  stat->uploadToRate > 0.01;
     375        stat->isUploading      =  stat->downloadFromRate > 0.01;
    371376
    372377#warning FIXME
    373378        //stat->progress = tr_peerProgress( peer );
    374379        //stat->client = tr_peerClient( peer );
    375         //stat->uploadToRate     =  tr_peerUploadRate( peer );
    376         //stat->downloadFromRate =  tr_peerDownloadRate( peer );
    377         //stat->isDownloading    =  peers[i].uploadToRate > 0.01;
    378         //stat->isUploading      =  peers[i].downloadFromRate > 0.01;
    379380    }
    380381
  • branches/encryption/libtransmission/peer-work.c

    r2955 r2963  
    115115
    116116    tr_timer_tag pulseTag;
    117 
    118     tr_ratecontrol * rcToUs;   /* rate of bytes from the peer to us */
    119     tr_ratecontrol * rcToPeer; /* rate of bytes from us to the peer */
    120117
    121118    unsigned int  peerIsChoked        : 1;
     
    533530
    534531    tor->downloadedCur += len;
    535     tr_rcTransferred( peer->rcToUs, len );
    536532    tr_rcTransferred( tor->download, len );
    537533    tr_rcTransferred( tor->handle->download, len );
     
    712708    sendBitfield( peer );
    713709}
    714 
    715 void
    716 tr_peerGetInfo( const tr_peer * peer, tr_peer_stat * setme )
    717 {
    718     setme->client = peer->client;
    719     setme->isConnected = TRUE;
    720     setme->progress = peer->progress;
    721     setme->downloadFromRate = tr_rcRate( peer->rcToUs );
    722     setme->downloadFromRate = tr_rcRate( peer->rcToPeer );
    723 
    724     //char    addr[INET_ADDRSTRLEN];
    725     //int     from;
    726     //int     port;
    727     //int     isDownloading;
    728     //int     isUploading;
    729 
    730 }
Note: See TracChangeset for help on using the changeset viewer.