]> granicus.if.org Git - transmission/commitdiff
Fix setting the ETA timestamps
authorgeertjan <gjalsem@gmail.com>
Mon, 19 Feb 2018 20:06:34 +0000 (21:06 +0100)
committerMike Gelfand <mikedld@mikedld.com>
Fri, 6 Apr 2018 19:52:29 +0000 (22:52 +0300)
Field etaDLSpeedCalculatedAt was set too early, causing the condition
following it to always be false. The same for etaULSpeedCalculatedAt.

libtransmission/torrent.c

index 54e31509f0b777efa8aae4dfcb8e8312986c894a..04dd922e1c4c5101b30ae1c59c6886b0e61aa22e 100644 (file)
@@ -1324,10 +1324,10 @@ tr_torrentStat (tr_torrent * tor)
       case TR_STATUS_DOWNLOAD:
         if ((tor->etaDLSpeedCalculatedAt + 800) < now)
           {
-            tor->etaDLSpeedCalculatedAt = now;
             tor->etaDLSpeed_Bps = ((tor->etaDLSpeedCalculatedAt + 4000) < now)
               ? pieceDownloadSpeed_Bps /* if no recent previous speed, no need to smooth */
               : ((tor->etaDLSpeed_Bps*4.0) + pieceDownloadSpeed_Bps)/5.0; /* smooth across 5 readings */
+            tor->etaDLSpeedCalculatedAt = now;
           }
 
         if ((s->leftUntilDone > s->desiredAvailable) && (tor->info.webseedCount < 1))
@@ -1349,10 +1349,10 @@ tr_torrentStat (tr_torrent * tor)
           {
             if ((tor->etaULSpeedCalculatedAt + 800) < now)
               {
-                tor->etaULSpeedCalculatedAt = now;
                 tor->etaULSpeed_Bps = ((tor->etaULSpeedCalculatedAt + 4000) < now)
                   ? pieceUploadSpeed_Bps /* if no recent previous speed, no need to smooth */
                   : ((tor->etaULSpeed_Bps*4.0) + pieceUploadSpeed_Bps)/5.0; /* smooth across 5 readings */
+                tor->etaULSpeedCalculatedAt = now;
               }
 
             if (tor->etaULSpeed_Bps == 0)