Bug 103382 - Stalled DCC tranfers show insane speed instead of 'stalled' or something
Summary: Stalled DCC tranfers show insane speed instead of 'stalled' or something
Status: RESOLVED FIXED
Alias: None
Product: konversation
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Shintaro Matsuoka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-06 22:51 UTC by Hein-Pieter van Braam
Modified: 2010-07-01 16:17 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hein-Pieter van Braam 2005-04-06 22:51:18 UTC
Version:           .16 (using KDE KDE 3.3.2)
Installed from:    Debian testing/unstable Packages
Compiler:          gcc 3.3.5 (probably, whatever was used for the 3.3.2 packages for sid) 
OS:                Linux

When a transfer stalls in konversation, insane speeds are shown instead of 'stalled' or something of the like. I've got a screenshot here: http://braam.sytes.net/~hp/amazing_speed.png 

It happened when my system was under an insane load, so that *might* have got something to do with it... not sure

good luck! and thanks for an amazing IRC client :)
Comment 1 Shintaro Matsuoka 2005-05-19 11:56:25 UTC
SVN commit 415680 by shin:

revise the CPS calculating algorithm completely (fixed the 24h problem).
CCBUG: 103382
Please check that the bug can no longer reproduced. Thank you for the report.

 M  +13 -7     trunk/extragear/network/konversation/src/dcctransfer.cpp  
 M  +1 -1      trunk/extragear/network/konversation/src/dcctransfer.h  


--- trunk/extragear/network/konversation/src/dcctransfer.cpp #415679:415680
@@ -164,7 +164,7 @@
   m_transferLoggerTimer = new QTimer( this );
   connect( m_transferLoggerTimer, SIGNAL( timeout() ), this, SLOT( slotLogTransfer() ) );
   m_timeTransferStarted = QDateTime::currentDateTime();
-  m_transferTime.start();
+  m_transferLoggerBaseTime.start();
   m_transferLoggerTimer->start( 100 );
   startAutoUpdateView();
 }
@@ -202,12 +202,8 @@
 
 void DccTransfer::slotLogTransfer()  // private
 {
-  // *************************************************************
-  // TODO: URGENT:
-  // QTime can't handle a longer time more than a day
-  // *************************************************************
-  kdDebug() << "transfer logger: " <<  m_transferTime.elapsed() << " " << m_transferringPosition << endl;
-  m_transferLogTime.append( m_transferTime.elapsed() );
+  kdDebug() << "DccTransfer::slotLogTransfer(): transfer logger: " <<  m_transferLoggerBaseTime.elapsed() << " " << m_transferringPosition << endl;
+  m_transferLogTime.append( m_transferLoggerBaseTime.elapsed() );
   m_transferLogPosition.append( m_transferringPosition );
 }
 
@@ -355,6 +351,8 @@
   if ( m_dccStatus == Sending || m_dccStatus == Receiving )
   {
     // update CPS
+    
+    // remove too old data
     QValueList<int>::iterator itTime = m_transferLogTime.begin();
     QValueList<KIO::fileoffset_t>::iterator itPos = m_transferLogPosition.begin();
     while ( itTime != m_transferLogTime.end() && ( m_transferLogTime.last() - (*itTime) > timeToCalc * 1000 ) )
@@ -362,6 +360,14 @@
       itTime = m_transferLogTime.remove( itTime );
       itPos = m_transferLogPosition.remove( itPos );
     }
+    
+    // shift the base of the time (m_transferLoggerBaseTime)
+    // why: QTime can't handle a longer time than 24 hours
+    int shiftOffset = m_transferLoggerBaseTime.restart();
+    itTime = m_transferLogTime.begin();
+    for ( ; itTime != m_transferLogTime.end() ; ++itTime )
+      (*itTime) = (*itTime) - shiftOffset;
+    
     if ( m_transferLogTime.count() >= 2 )
       m_cps = (double)( m_transferLogPosition.last() - m_transferLogPosition.front() ) / (double)( m_transferLogTime.last() - m_transferLogTime.front() ) * 1000;
     else  // avoid zero devision
--- trunk/extragear/network/konversation/src/dcctransfer.h #415679:415680
@@ -185,7 +185,7 @@
     QDateTime m_timeTransferFinished;
     
     QTimer* m_transferLoggerTimer;
-    QTime m_transferTime;  // it's used for calculating CPS
+    QTime m_transferLoggerBaseTime;  // it's used for calculating CPS
     QValueList<int> m_transferLogTime;
     QValueList<KIO::fileoffset_t> m_transferLogPosition;
 
Comment 2 Ismail Donmez 2005-06-04 11:31:04 UTC
Works fine here now. Thanks Shin!
Comment 3 Shintaro Matsuoka 2010-07-01 16:17:01 UTC
commit d098c4f1eb67ff102b54f0c48045166e18027df2
Author: Shintaro Matsuoka <shin@shoegazed.org>
Date:   Thu May 19 09:55:51 2005 +0000

    revise the CPS calculating algorithm completely (fixed the 24h problem).
    CCBUG: 103382
    Please check that the bug can no longer reproduced. Thank you for the report.
    
    svn path=/trunk/extragear/network/konversation/; revision=415680

diff --git a/src/dcctransfer.cpp b/src/dcctransfer.cpp
index 07cfdfe..986fd82 100644
--- a/src/dcctransfer.cpp
+++ b/src/dcctransfer.cpp
@@ -164,7 +164,7 @@ void DccTransfer::initTransferMeter()  // protected
   m_transferLoggerTimer = new QTimer( this );
   connect( m_transferLoggerTimer, SIGNAL( timeout() ), this, SLOT( slotLogTransfer() ) );
   m_timeTransferStarted = QDateTime::currentDateTime();
-  m_transferTime.start();
+  m_transferLoggerBaseTime.start();
   m_transferLoggerTimer->start( 100 );
   startAutoUpdateView();
 }
@@ -202,12 +202,8 @@ void DccTransfer::stopAutoUpdateView()
 
 void DccTransfer::slotLogTransfer()  // private
 {
-  // *************************************************************
-  // TODO: URGENT:
-  // QTime can't handle a longer time more than a day
-  // *************************************************************
-  kdDebug() << "transfer logger: " <<  m_transferTime.elapsed() << " " << m_transferringPosition << endl;
-  m_transferLogTime.append( m_transferTime.elapsed() );
+  kdDebug() << "DccTransfer::slotLogTransfer(): transfer logger: " <<  m_transferLoggerBaseTime.elapsed() << " " << m_transferringPosition << endl;
+  m_transferLogTime.append( m_transferLoggerBaseTime.elapsed() );
   m_transferLogPosition.append( m_transferringPosition );
 }
 
@@ -355,6 +351,8 @@ void DccTransfer::updateTransferMeters()
   if ( m_dccStatus == Sending || m_dccStatus == Receiving )
   {
     // update CPS
+    
+    // remove too old data
     QValueList<int>::iterator itTime = m_transferLogTime.begin();
     QValueList<KIO::fileoffset_t>::iterator itPos = m_transferLogPosition.begin();
     while ( itTime != m_transferLogTime.end() && ( m_transferLogTime.last() - (*itTime) > timeToCalc * 1000 ) )
@@ -362,6 +360,14 @@ void DccTransfer::updateTransferMeters()
       itTime = m_transferLogTime.remove( itTime );
       itPos = m_transferLogPosition.remove( itPos );
     }
+    
+    // shift the base of the time (m_transferLoggerBaseTime)
+    // why: QTime can't handle a longer time than 24 hours
+    int shiftOffset = m_transferLoggerBaseTime.restart();
+    itTime = m_transferLogTime.begin();
+    for ( ; itTime != m_transferLogTime.end() ; ++itTime )
+      (*itTime) = (*itTime) - shiftOffset;
+    
     if ( m_transferLogTime.count() >= 2 )
       m_cps = (double)( m_transferLogPosition.last() - m_transferLogPosition.front() ) / (double)( m_transferLogTime.last() - m_transferLogTime.front() ) * 1000;
     else  // avoid zero devision
diff --git a/src/dcctransfer.h b/src/dcctransfer.h
index bd1c85d..b95bcb0 100644
--- a/src/dcctransfer.h
+++ b/src/dcctransfer.h
@@ -185,7 +185,7 @@ class DccTransfer : public QObject, public KListViewItem
     QDateTime m_timeTransferFinished;
     
     QTimer* m_transferLoggerTimer;
-    QTime m_transferTime;  // it's used for calculating CPS
+    QTime m_transferLoggerBaseTime;  // it's used for calculating CPS
     QValueList<int> m_transferLogTime;
     QValueList<KIO::fileoffset_t> m_transferLogPosition;