From 28d43da1d1e9f8d479f99146d2b748c1f5305e5b Mon Sep 17 00:00:00 2001 From: Eric Petit Date: Mon, 30 Jan 2006 02:13:40 +0000 Subject: [PATCH] Removed now unused tables and some now unused code --- libtransmission/internal.h | 6 +++--- libtransmission/peer.c | 18 ++++++------------ libtransmission/peerparse.h | 14 +++----------- libtransmission/tracker.c | 2 +- libtransmission/transmission.c | 17 +++++------------ 5 files changed, 18 insertions(+), 39 deletions(-) diff --git a/libtransmission/internal.h b/libtransmission/internal.h index 47102de36..751601a21 100644 --- a/libtransmission/internal.h +++ b/libtransmission/internal.h @@ -146,9 +146,9 @@ struct tr_torrent_s int peerCount; tr_peer_t * peers[TR_MAX_PEER_COUNT]; - uint64_t dates[10]; - uint64_t downloaded[10]; - uint64_t uploaded[10]; + uint64_t date; + uint64_t downloaded; + uint64_t uploaded; }; #include "utils.h" diff --git a/libtransmission/peer.c b/libtransmission/peer.c index 27f72f555..c3da194df 100644 --- a/libtransmission/peer.c +++ b/libtransmission/peer.c @@ -244,7 +244,7 @@ int tr_peerRead( tr_torrent_t * tor, tr_peer_t * peer ) { tr_rcTransferred( tor->download, ret ); tr_rcTransferred( tor->globalDownload, ret ); - if( parseBuf( tor, peer, ret ) ) + if( parseBuf( tor, peer ) ) { return 1; } @@ -282,15 +282,9 @@ void tr_peerPulse( tr_torrent_t * tor ) uint8_t * p; tr_peer_t * peer; - tor->dates[9] = tr_date(); - if( tor->dates[9] > tor->dates[8] + 1000 ) + if( tr_date() > tor->date + 1000 ) { - memmove( &tor->downloaded[0], &tor->downloaded[1], - 9 * sizeof( uint64_t ) ); - memmove( &tor->uploaded[0], &tor->uploaded[1], - 9 * sizeof( uint64_t ) ); - memmove( &tor->dates[0], &tor->dates[1], - 9 * sizeof( uint64_t ) ); + tor->date = tr_date(); for( i = 0; i < tor->peerCount; ) { @@ -379,9 +373,9 @@ writeBegin: tr_rcTransferred( tor->upload, ret ); tr_rcTransferred( tor->globalUpload, ret ); - tor->uploaded[9] += ret; - peer->outTotal += ret; - peer->outDate = tr_date(); + tor->uploaded += ret; + peer->outTotal += ret; + peer->outDate = tr_date(); /* In case this block is done, you may have messages pending. Send them before we start the next block */ diff --git a/libtransmission/peerparse.h b/libtransmission/peerparse.h index db8e8ec9c..8a3251bfb 100644 --- a/libtransmission/peerparse.h +++ b/libtransmission/peerparse.h @@ -268,6 +268,8 @@ static inline int parsePiece( tr_torrent_t * tor, tr_peer_t * peer, return 1; } + tor->downloaded += r->length; + block = tr_block( r->index, r->begin ); if( tr_cpBlockIsComplete( tor->completion, block ) ) { @@ -438,8 +440,7 @@ static uint8_t * parseBufHash( tr_peer_t * peer ) } } -static inline int parseBuf( tr_torrent_t * tor, tr_peer_t * peer, - int newBytes ) +static inline int parseBuf( tr_torrent_t * tor, tr_peer_t * peer ) { tr_info_t * inf = &tor->info; @@ -523,15 +524,6 @@ static inline int parseBuf( tr_torrent_t * tor, tr_peer_t * peer, continue; } - /* That's a piece coming */ - if( p < end && *p == 7 ) - { - /* XXX */ - tor->downloaded[9] += newBytes; - peer->inTotal += newBytes; - newBytes = 0; - } - if( &p[len] > end ) { /* We do not have the entire message */ diff --git a/libtransmission/tracker.c b/libtransmission/tracker.c index 1ac0e8ec6..eea8ae112 100644 --- a/libtransmission/tracker.c +++ b/libtransmission/tracker.c @@ -282,7 +282,7 @@ static void sendQuery( tr_tracker_t * tc ) "User-Agent: Transmission/%d.%d\r\n" "Connection: close\r\n\r\n", inf->trackerAnnounce, tor->hashString, tc->id, - tc->bindPort, tor->uploaded[9], tor->downloaded[9], + tc->bindPort, tor->uploaded, tor->downloaded, left, tor->key, event, inf->trackerAddress, VERSION_MAJOR, VERSION_MINOR ); diff --git a/libtransmission/transmission.c b/libtransmission/transmission.c index 52805af56..aeb156c2c 100644 --- a/libtransmission/transmission.c +++ b/libtransmission/transmission.c @@ -278,8 +278,6 @@ char * tr_torrentGetFolder( tr_handle_t * h, int t ) void tr_torrentStart( tr_handle_t * h, int t ) { tr_torrent_t * tor = h->torrents[t]; - uint64_t now; - int i; if( tor->status & ( TR_STATUS_STOPPING | TR_STATUS_STOPPED ) ) { @@ -290,12 +288,7 @@ void tr_torrentStart( tr_handle_t * h, int t ) tor->status = TR_STATUS_CHECK; tor->tracker = tr_trackerInit( h, tor ); - now = tr_date(); - for( i = 0; i < 10; i++ ) - { - tor->dates[i] = now; - } - + tor->date = tr_date(); tor->die = 0; tr_threadCreate( &tor->thread, downloadLoop, tor ); } @@ -331,8 +324,8 @@ static void torrentReallyStop( tr_handle_t * h, int t ) tr_peerRem( tor, 0 ); } - memset( tor->downloaded, 0, sizeof( tor->downloaded ) ); - memset( tor->uploaded, 0, sizeof( tor->uploaded ) ); + tor->downloaded = 0; + tor->uploaded = 0; } /*********************************************************************** @@ -451,8 +444,8 @@ int tr_torrentStat( tr_handle_t * h, tr_stat_t ** stat ) } } - s[i].downloaded = tor->downloaded[9]; - s[i].uploaded = tor->uploaded[9]; + s[i].downloaded = tor->downloaded; + s[i].uploaded = tor->uploaded; s[i].folder = tor->destination;