diff --git a/libtransmission/tracker.c b/libtransmission/tracker.c index 01a0f11e3..a53c0e866 100644 --- a/libtransmission/tracker.c +++ b/libtransmission/tracker.c @@ -54,6 +54,9 @@ struct tr_tracker_s int bindPort; int newPort; + + uint64_t download; + uint64_t upload; }; static void sendQuery ( tr_tracker_t * tc ); @@ -79,6 +82,9 @@ tr_tracker_t * tr_trackerInit( tr_torrent_t * tor ) tc->bindPort = *(tor->bindPort); tc->newPort = -1; + tc->download = tor->downloaded; + tc->upload = tor->uploaded; + return tc; } @@ -267,21 +273,34 @@ static void sendQuery( tr_tracker_t * tc ) char * event; uint64_t left; int ret; + uint64_t down; + uint64_t up; - if( tc->started && 0 < tc->newPort ) - { - tc->bindPort = tc->newPort; - tc->newPort = -1; - } - + down = tor->downloaded - tc->download; + up = tor->uploaded - tc->upload; if( tc->started ) + { event = "&event=started"; + down = up = 0; + + if( 0 < tc->newPort ) + { + tc->bindPort = tc->newPort; + tc->newPort = -1; + } + } else if( tc->completed ) + { event = "&event=completed"; + } else if( tc->stopped || 0 < tc->newPort ) + { event = "&event=stopped"; + } else + { event = ""; + } left = tr_cpLeftBytes( tor->completion ); @@ -302,7 +321,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, tor->downloaded, + tc->bindPort, up, down, left, tor->key, event, inf->trackerAddress, VERSION_MAJOR, VERSION_MINOR ); diff --git a/libtransmission/transmission.c b/libtransmission/transmission.c index fe6ecd978..189ac4923 100644 --- a/libtransmission/transmission.c +++ b/libtransmission/transmission.c @@ -302,7 +302,6 @@ void tr_torrentStart( tr_torrent_t * tor ) } tor->status = TR_STATUS_CHECK; - tor->tracker = tr_trackerInit( tor ); tor->date = tr_date(); tor->die = 0; @@ -557,6 +556,7 @@ static void downloadLoop( void * _tor ) tor->io = tr_ioInit( tor ); tor->status = tr_cpIsSeeding( tor->completion ) ? TR_STATUS_SEED : TR_STATUS_DOWNLOAD; + tor->tracker = tr_trackerInit( tor ); while( !tor->die ) {