mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-11 16:59:25 -04:00
fixed potential div by 0 in speed estimations. To be tested.
This commit is contained in:
parent
b148239e4f
commit
a52bd98d4b
1 changed files with 4 additions and 2 deletions
|
@ -183,8 +183,10 @@ void pqistreamer::updateRates()
|
|||
|
||||
if (t > mAvgLastUpdate + PQISTREAM_AVG_PERIOD)
|
||||
{
|
||||
float avgReadpSec = getRate(true) * PQISTREAM_AVG_FRAC + (1.0 - PQISTREAM_AVG_FRAC) * mAvgReadCount/(1000.0 * (t - mAvgLastUpdate));
|
||||
float avgSentpSec = getRate(false) * PQISTREAM_AVG_FRAC + (1.0 - PQISTREAM_AVG_FRAC) * mAvgSentCount/(1000.0 * (t - mAvgLastUpdate));
|
||||
int64_t diff = int64_t(t) - int64_t(mAvgLastUpdate) ;
|
||||
|
||||
float avgReadpSec = getRate(true) * PQISTREAM_AVG_FRAC + (1.0 - PQISTREAM_AVG_FRAC) * mAvgReadCount/(1000.0 * float(diff));
|
||||
float avgSentpSec = getRate(false) * PQISTREAM_AVG_FRAC + (1.0 - PQISTREAM_AVG_FRAC) * mAvgSentCount/(1000.0 * float(diff));
|
||||
|
||||
#ifdef DEBUG_PQISTREAMER
|
||||
std::cerr << "Peer " << PeerId() << ": Current speed estimates: " << avgReadpSec << " / " << avgSentpSec << std::endl;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue