From 38d6b03a8e2f87ca4a78e324e0ae6ca36867f509 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 13 Oct 2007 23:57:13 +0000 Subject: [PATCH] report a speed of 0 when no peers are connected. --- libtransmission/torrent.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index 3a452646d..db89a8e08 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -722,14 +722,16 @@ tr_torrentStat( tr_torrent * tor ) s->cpStatus = tor->cpStatus; - /* tr_rcRate() doesn't make the difference between 'piece' - messages and other messages, which causes a non-zero - download rate even tough we are not downloading. So we - force it to zero not to confuse the user. */ - s->rateDownload = tor->isRunning - ? tr_rcRate( tor->download ) - : 0.0; - s->rateUpload = tr_rcRate( tor->upload ); + /* rcRate's averaging code can make it appear that we're + * still sending bytes after a torrent stops or all the + * peers disconnect, so short-circuit that appearance here */ + if( tor->isRunning && s->peersConnected ) { + s->rateDownload = tr_rcRate( tor->download ); + s->rateUpload = tr_rcRate( tor->upload ); + } else { + s->rateDownload = 0.0; + s->rateUpload = 0.0; + } tr_trackerGetCounts( tc, &s->completedFromTracker,