Ignore:
Timestamp:
Nov 21, 2007, 8:03:53 PM (15 years ago)
Author:
charles
Message:

some progress on the overall statistics, though probably not visible to end users yet

File:
1 edited

Legend:

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

    r3906 r3921  
    3333#include "peer-msgs.h"
    3434#include "ratecontrol.h"
     35#include "stats.h"
    3536#include "trevent.h"
    3637#include "utils.h"
     
    784785
    785786    /* does the peer prefer encrypted connections? */
    786     sub = tr_bencDictFind( &val, "e" );
    787     if( tr_bencIsInt( sub ) )
     787    if(( sub = tr_bencDictFindType( &val, "e", TYPE_INT )))
    788788        msgs->info->encryption_preference = sub->val.i
    789789                                      ? ENCRYPTION_PREFERENCE_YES
     
    791791
    792792    /* check supported messages for utorrent pex */
    793     sub = tr_bencDictFind( &val, "m" );
    794     if( tr_bencIsDict( sub ) ) {
    795         sub = tr_bencDictFind( sub, "ut_pex" );
    796         if( tr_bencIsInt( sub ) ) {
     793    if(( sub = tr_bencDictFindType( &val, "m", TYPE_DICT ))) {
     794        if(( sub = tr_bencDictFindType( sub, "ut_pex", TYPE_INT ))) {
    797795            msgs->peerSupportsPex = 1;
    798796            msgs->ut_pex_id = (uint8_t) sub->val.i;
     
    802800
    803801    /* get peer's listening port */
    804     sub = tr_bencDictFind( &val, "p" );
    805     if( tr_bencIsInt( sub ) ) {
     802    if(( sub = tr_bencDictFindType( &val, "p", TYPE_INT ))) {
    806803        msgs->info->port = htons( (uint16_t)sub->val.i );
    807804        dbgmsg( msgs, "msgs->port is now %hu", msgs->info->port );
     
    824821    tr_peerIoReadBytes( msgs->io, inbuf, tmp, msglen );
    825822
    826     if( tr_bencLoad( tmp, msglen, &val, NULL ) || !tr_bencIsDict( &val ) ) {
     823    if( tr_bencLoad( tmp, msglen, &val, NULL ) || ( val.type != TYPE_DICT ) ) {
    827824        dbgmsg( msgs, "GET can't read extended-pex dictionary" );
    828825        tr_free( tmp );
     
    830827    }
    831828
    832     sub = tr_bencDictFind( &val, "added" );
    833     if( tr_bencIsStr(sub) && ((sub->val.s.i % 6) == 0)) {
     829    if(( sub = tr_bencDictFindType( &val, "added", TYPE_STR ))) {
    834830        const int n = sub->val.s.i / 6 ;
    835831        dbgmsg( msgs, "got %d peers from uT pex", n );
     
    10431039    tr_rcTransferred( tor->download, byteCount );
    10441040    tr_rcTransferred( tor->handle->download, byteCount );
    1045 }
    1046 
     1041    tr_statsAddDownloaded( msgs->handle, byteCount );
     1042}
    10471043
    10481044static int
     
    12671263    tr_rcTransferred( tor->upload, byteCount );
    12681264    tr_rcTransferred( tor->handle->upload, byteCount );
     1265    tr_statsAddUploaded( msgs->handle, byteCount );
    12691266}
    12701267
Note: See TracChangeset for help on using the changeset viewer.