diff --git a/libtransmission/peer-io.c b/libtransmission/peer-io.c index 109a4ed3d..3e1f46088 100644 --- a/libtransmission/peer-io.c +++ b/libtransmission/peer-io.c @@ -30,6 +30,7 @@ #include "net.h" #include "peer-io.h" #include "ratecontrol.h" +#include "stats.h" /* tr_statsAddUploaded(), tr_statsAddDownloaded() */ #include "trevent.h" #include "utils.h" @@ -181,6 +182,7 @@ didWriteWrapper( struct bufferevent * e, b->bytesLeft -= MIN( b->bytesLeft, (size_t)n ); b->bytesUsed += n; tr_rcTransferred( io->speedometer[TR_UP], n ); + tr_statsAddUploaded( io->session, n ); dbgmsg( io, "wrote %zu bytes to peer... upload bytesLeft is now %zu", n, @@ -213,6 +215,7 @@ canReadWrapper( struct bufferevent * e, b->bytesLeft -= MIN( b->bytesLeft, (size_t)n ); b->bytesUsed += n; tr_rcTransferred( io->speedometer[TR_DOWN], n ); + tr_statsAddDownloaded( io->session, n ); dbgmsg( io, "%zu new input bytes. bytesUsed is %zu, bytesLeft is %zu", n, b->bytesUsed, diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index 1f8532341..40a3828a3 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -31,7 +31,6 @@ #include "peer-mgr-private.h" #include "peer-msgs.h" #include "ptrarray.h" -#include "stats.h" /* tr_statsAddDownloaded */ #include "torrent.h" #include "trevent.h" #include "utils.h" @@ -1008,7 +1007,6 @@ peerCallbackFunc( void * vpeer, tr_torrent * tor = t->tor; tor->activityDate = now; tor->uploadedCur += e->length; - tr_statsAddUploaded( tor->session, e->length ); if( peer ) { struct peer_atom * a = getExistingAtom( t, &peer->in_addr ); @@ -1030,7 +1028,6 @@ peerCallbackFunc( void * vpeer, * into the jurisdiction of the tracker." */ if( peer ) tor->downloadedCur += e->length; - tr_statsAddDownloaded( tor->session, e->length ); if( peer ) { struct peer_atom * a = getExistingAtom( t, &peer->in_addr ); a->piece_data_time = now; diff --git a/libtransmission/stats.h b/libtransmission/stats.h index 79e36a3e0..262a676eb 100644 --- a/libtransmission/stats.h +++ b/libtransmission/stats.h @@ -13,16 +13,16 @@ #ifndef TR_STATS_H #define TR_STATS_H -void tr_statsInit( tr_handle * handle ); +void tr_statsInit ( tr_session * session ); -void tr_statsClose( tr_handle * handle ); +void tr_statsClose ( tr_session * session ); -void tr_statsAddUploaded( tr_handle * handle, - uint32_t bytes ); +void tr_statsAddUploaded ( tr_session * session, + uint32_t bytes ); -void tr_statsAddDownloaded( tr_handle * handle, - uint32_t bytes ); +void tr_statsAddDownloaded ( tr_session * session, + uint32_t bytes ); -void tr_statsFileCreated( tr_handle * handle ); +void tr_statsFileCreated ( tr_session * session ); #endif